QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#76274 | #5455. TreeScript | moyujiang | WA | 7ms | 8588kb | C++14 | 765b | 2023-02-08 21:32:12 | 2023-02-08 21:32:15 |
Judging History
answer
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a),i##END=(b);i<=i##END;i++)
#define Rof(i,b,a) for(int i=(b),i##END=(a);i>=i##END;i--)
#define go(u) for(int i=head[u];i;i=nxt[i])
using namespace std;
inline int read(){
int x=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
return x*f;
}
const int N=2e5+10;
int n,p[N];vector<int> g[N];
int a[N];
signed main(){
int T=read();while(T--){
For(i,1,n=read())p[i]=read(),g[i].clear(),a[i]=0;
For(i,2,n)g[p[i]].push_back(i);
For(i,1,n)if(g[i].size())a[g[i][0]]++,a[g[i].back()]--;
int ans=1;
For(i,1,n)ans=max(ans,(a[i]+=a[i-1]));
cout<<ans<<endl;
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 8588kb
input:
2 3 0 1 2 7 0 1 2 2 1 4 1
output:
1 2
result:
ok 2 number(s): "1 2"
Test #2:
score: -100
Wrong Answer
time: 7ms
memory: 8492kb
input:
1000 197 0 1 1 2 1 4 1 5 8 3 5 1 4 7 12 14 4 7 10 9 12 11 16 10 21 19 22 17 25 13 28 9 5 15 26 26 33 25 15 1 35 6 32 17 37 8 19 43 19 27 29 9 30 6 31 27 35 35 37 13 28 38 57 31 38 8 22 14 33 9 18 62 52 37 10 19 22 60 54 12 38 59 64 65 80 82 28 60 85 78 27 25 71 14 52 6 59 14 87 32 33 41 59 41 88 38 ...
output:
27 21 3 18 9 10 35 42 10 15 19 25 55 45 6 7 33 107 9 40 89 5 29 33 28 17 83 8 17 61 1 58 18 4 40 18 5 10 4 17 20 13 9 2 10 12 47 49 14 16 16 3 15 32 69 22 11 36 13 27 44 40 3 39 23 12 8 20 56 20 15 61 59 16 28 53 1 5 27 1 1 75 58 13 8 11 41 87 24 36 35 36 20 23 8 10 19 11 22 25 39 40 20 81 30 38 4 3...
result:
wrong answer 1st numbers differ - expected: '4', found: '27'