提交时间:2024-01-22 21:52:30
运行 ID: 123381
#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 <= m ; i ++ ) { if ( tree [i] . ft = 0 ) { cout << i << ' ' ; } if ( tree [i] . cld > maxn ) { maxn = tree [i] . cld ; cur = i ; } } cout << cur << endl ; return 0 ; }