Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
125170 宋春霖 树根和宝藏 C++ 解答错误 0 0 MS 244 KB 512 2024-01-23 16:30:56

Tests(0/8):


#include<bits/stdc++.h> using namespace std; int n, m, tree[1005]; int main(){ int root, maxr, sum = 0, maxx = 0; cin >> n >> m; for (int i = 1; i <= m; i++){ int x, y; cin >> x >> y; tree[y] = x; } for (int i = 1; i <= n; i++){ if (tree[i] == 0) { root = i; break; } } for (int i = 1; i <= n; i++){ sum = 0; for(int j = 1; j <= n; j++){ if (tree[j] == i) sum ++; } if (sum > maxx){ maxx = sum; maxr = i; } } cout << root << maxr << endl; }


测评信息: