| Run ID | Author | Problem | Lang | Verdict | Score | Time | Memory | Code Length | Submit Time |
|---|---|---|---|---|---|---|---|---|---|
| 121600 | 魈凯KBS | 树根和宝藏 | C++ | Accepted | 100 | 0 MS | 252 KB | 625 | 2024-01-22 08:01:35 |
#include <bits/stdc++.h> using namespace std; int n, m, MAX, tmp, x[2013]; struct Tree { int root, num[201]; } f; int main() { int root; cin >> n >> m; for(int i=1,y; i<=m; i++) { cin >> x[i] >> y; if(i == 1) f.root = x[1]; if(y == f.root) f.root = x[i]; f.num[x[i]]++; } for(int i=1; i<=m; i++) { if(x[i] == x[i-1]) continue; else if(f.num[x[i]] > MAX) { tmp = x[i]; MAX = f.num[x[i]]; } } cout << f.root << ' ' << tmp << '\n'; return 0; }