QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#602575 | #8720. BFS 序 0 | frs# | WA | 57ms | 22064kb | C++14 | 1.3kb | 2024-10-01 10:51:45 | 2024-10-01 10:51:50 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<vector>
using namespace std;
const int N = 5e5 + 5;
int n, qr, m, cnt[N], a[N];
bool f[N];
vector<int> ve[N];
struct qnode{
int id, d;
qnode(int id1 = 0, int d1 = 0){
id = id1;
d = d1;
}
}tp;
queue<qnode> q;
int main(){
scanf("%d", &n);
int u;
for(int i = 2; i <= n; i++){
scanf("%d", &u);
ve[u].push_back(i);
}
q.push(qnode(1, 1));
while(!q.empty()){
tp = q.front();
q.pop();
cnt[tp.id] = tp.d;
int sz = ve[tp.id].size();
for(int i = 0; i < sz; i++){
q.push(qnode(ve[tp.id][i], tp.d + 1));
}
}
scanf("%d", &qr);
while(qr--){
scanf("%d", &m);
for(int i = 1; i <= m; i++){
scanf("%d", &a[i]);
f[a[i]] = 0;
}
bool flag = 1;
f[a[1]] = 1;
for(int i = 2; i <= m; i++){
if(cnt[a[i]] < cnt[a[i - 1]]){
flag = 0;
break;
}
if(f[a[i]]){
flag = 0;
break;
}
f[a[i]] = 1;
}
if(!flag) printf("No\n");
else printf("Yes\n");
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 18596kb
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: 57ms
memory: 22064kb
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]