提交时间:2024-01-22 23:27:32

运行 ID: 123432

#include<bits/stdc++.h> using namespace std; int main(){ int j,n,m,i,a[10000] = {0},x,maxr,y,gen,max = -999999; cin>>n>>m; for(i = 1;i <= m;i++){ cin>>x>>y; a[y] = x; } for(i = 1;i <= n;i++){ if(a[i] == 0){ gen = i; break; } } int s; for(i = 1;i <= n;i++){ s = 0; for(j = 1;j <= n;j++){ if(a[j] == i){ s++; } } if(s > max){ max = s; maxr = i; } } cout<<gen<<" "<<maxr<<endl; }