QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#793590 | #8720. BFS 序 0 | Kdlyh# | WA | 41ms | 5516kb | C++20 | 889b | 2024-11-29 21:25:12 | 2024-11-29 21:25:13 |
Judging History
answer
#include "bits/stdc++.h"
const int N = 300100;
int n, m;
int dep[N];
int len, seq[N];
bool exist[N];
int main() {
scanf("%d", &n);
for (int i = 2, x; i <= n; i ++) {
scanf("%d", &x);
dep[i] = dep[x] + 1;
}
scanf("%d", &m);
while (m --) {
scanf("%d", &len);
int d = -1, flag = 1;
for (int i = 1; i <= len; i ++) {
scanf("%d", &seq[i]);
if (exist[seq[i]]) flag = 0;
else exist[seq[i]] = 1;
}
d = dep[seq[1]];
for (int i = 2; i <= len; i ++)
if (dep[seq[i]] >= d)
d = dep[seq[i]];
else
flag = 0;
for (int i = 1; i <= len; i ++)
exist[seq[i]] = 0;
if (flag)
puts("Yes");
else
puts("No");
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3712kb
input:
6 1 1 3 2 4 10 4 3 6 2 5 1 4 3 2 4 5 5 2 5 4 6 3 3 1 4 2 3 5 6 3 5 4 5 2 6 1 4 4 3 2 5 4 4 6 2 3 3 3 2 6
output:
No Yes Yes No No No No No No Yes
result:
ok 10 token(s): yes count is 3, no count is 7
Test #2:
score: -100
Wrong Answer
time: 41ms
memory: 5516kb
input:
300000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
output:
No Yes Yes Yes No No No No No No Yes Yes No Yes No Yes Yes Yes No No No No Yes No No Yes No No No No Yes Yes Yes No No Yes No No No No No No No Yes No Yes No Yes No No No No Yes Yes Yes No No Yes No No No No No Yes Yes No No No No No Yes Yes No Yes No No No Yes No No Yes No No Yes Yes Yes Yes No No ...
result:
wrong answer expected NO, found YES [87th token]