QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#398717 | #5455. TreeScript | iwew# | WA | 9ms | 3656kb | C++20 | 822b | 2024-04-25 17:02:05 | 2024-04-25 17:02:07 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 200010;
int v[N];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int T;
cin >> T;
while(T -- ) {
int n;
cin >> n;
vector<int> p(n);
for(int i = 0; i < n; i ++ ) cin >> p[i];
for(int i = 0; i < n; i ++ ) {
if(p[i]) {
v[p[i]] ++ ;
}
}
int used = 1, now = 1;
for(int i = 1; i < n; i ++ ) {
v[p[i]] -- ;
if(v[p[i]] && v[i + 1]) {
now ++ ;
if(now > used) used = now;
} else if(!v[p[i]] && !v[i + 1]) {
now -- ;
}
}
cout << used << '\n';
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3488kb
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: 9ms
memory: 3656kb
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:
46 40 4 36 16 20 69 77 14 32 34 41 118 91 11 12 61 212 13 88 170 8 53 63 55 35 168 17 31 123 4 113 26 9 84 32 8 17 9 28 36 28 20 7 19 23 97 97 24 33 28 5 27 61 133 42 26 67 23 50 88 69 5 69 47 28 18 42 113 38 30 122 111 29 59 100 3 8 51 1 1 145 108 24 12 22 81 169 45 64 57 70 35 39 14 18 32 18 42 49...
result:
wrong answer 1st numbers differ - expected: '4', found: '46'