提交时间:2024-01-23 14:53:15
运行 ID: 124507
#include <bits/stdc++.h> using namespace std ; struct tr { int ft = 0 , cld = 0 ; } ; tr tree [114514] ; int main ( ) { int n , m ; cin >> n >> m ; for ( int i = 1 ; i <= m ; i ++ ) { int x , y ; cin >> x >> y ; tree [x] . cld ++ ; tree [y] . ft ++ ; } int maxn = 0 , cur ; for ( int i = 1 ; i <= n ; i ++ ) { if ( tree [i] . ft == 0 ) { cout << i << ' ' ; } if ( tree [i] . cld > maxn ) { maxn = tree [i] . cld ; cur = i ; } } cout << cur << endl ; return 0 ; }