Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
121445 陈志轩 树根和宝藏 C++ 通过 100 0 MS 264 KB 1244 2024-01-21 19:12:10

Tests(8/8):


#include<bits/stdc++.h> #define int long long using namespace std; namespace Fast{ inline int fr(){ register int x = 0,f = 1; static char c = getchar(); while (c < '0' || c > '9'){ if (c == '-'){ f = -1; } c = getchar(); } while (c >= '0' && c <= '9'){ x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); } return x * f; } inline void fw(int x){ if (x == 0){ putchar('0'); return ; } if (x < 0){ putchar('-'); x = -x; } stack <char> s; while (x){ s.push(x % 10 + 48); x /= 10; } while (!s.empty()){ putchar(s.top()); s.pop(); } } inline void DEBUG(){ puts("awa"); } inline void CCF(){ ios::sync_with_stdio(false); cin.tie(0),cout.tie(0); } } using namespace Fast; int fa[1005],cnt[1005]; signed main(){ memset(fa,0x3f3f3f3f,sizeof(fa)); int n,m; n = fr(),m = fr(); for (int i = 1;i <= m;i++){ int u,v; u = fr(),v = fr(); fa[v] = u; cnt[u]++; } for (int i = 1;i <= n;i++){ if (fa[i] >= 0x3f3f3f3f){ cout<<i<<' '; break; } } int maxn = 0,maxi = 0; for (int i = 1;i <= n;i++){ if (cnt[i] > maxn){ maxn = cnt[i],maxi = i; } } cout<<maxi; return 0; }


测评信息: