QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#584771 | #9184. Team Coding | chengning0909 | Compile Error | / | / | C++20 | 680b | 2024-09-23 16:41:16 | 2024-09-23 16:41:17 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, k, a[N], dep[N];
vector<int> g[N];
bool flag = 1;
void dfs(int u) {
for (int v : g[u]) dfs(v);
}
int main() {
ios::sync_with_stdio(0), cin.tie(0);
cin >> n >> k;
for (int i = 1; i <= n; i++) cin >> a[i];
for (int i = 2, fa; i <= n; i++) {
cin >> fa, fa++, g[fa].push_back(i);
flag &= fa == i - 1;
}
if (flag) {
for (int i = n; i >= 1; i--) {
cnt[a[i]]++;
ans = max(ans, cnt[a[i]]);
}
cout << ans << " 0";
} else if (n <= 2000) {
dfs(1);
}
return 0;
}
详细
answer.code: In function ‘int main()’: answer.code:26:13: error: ‘cnt’ was not declared in this scope; did you mean ‘int’? 26 | cnt[a[i]]++; | ^~~ | int answer.code:27:13: error: ‘ans’ was not declared in this scope; did you mean ‘abs’? 27 | ans = max(ans, cnt[a[i]]); | ^~~ | abs answer.code:29:17: error: ‘ans’ was not declared in this scope; did you mean ‘abs’? 29 | cout << ans << " 0"; | ^~~ | abs