QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#75837 | #5455. TreeScript | XKError | Compile Error | / | / | C++14 | 638b | 2023-02-06 12:47:54 | 2023-02-06 12:47:57 |
Judging History
你现在查看的是最新测评结果
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2023-02-06 12:47:57]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-02-06 12:47:54]
- 提交
answer
#include <bits/stdc++.h>
#define maxn 200005
using namespace std;
int T;
int n;
int f[maxn];
vector<int> g[maxn];
void dfs(int u, int fa) {
int mx = 0, cm = -1;
for (int v : g[u]) {
dfs(v, u);
if (f[v] >= mx) cm = mx, mx = f[v];
else if (f[v] >= cm) cm = f[v];
}
f[u] = max(mx, cm + 1);
}
int main() {
scanf("%d", &T);
while (T--) {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
int x;
scanf("%d", &x);
if (x) g[x].push_back(i);
}
dfs(1, 0);
printf("%d\n", f[1]);
for (int i = 1; i <= n; i++) vec[i].clear();
}
return 0;
}
/*
2
3
0 1 2
7
0 1 2 2 1 4 1
*/
Details
answer.code: In function ‘int main()’: answer.code:33:46: error: ‘vec’ was not declared in this scope 33 | for (int i = 1; i <= n; i++) vec[i].clear(); | ^~~ answer.code:23:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 23 | scanf("%d", &T); | ~~~~~^~~~~~~~~~ answer.code:25:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 25 | scanf("%d", &n); | ~~~~~^~~~~~~~~~ answer.code:28:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 28 | scanf("%d", &x); | ~~~~~^~~~~~~~~~