QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#602554 | #8720. BFS 序 0 | frs# | WA | 0ms | 11540kb | C++14 | 1.1kb | 2024-10-01 10:41:16 | 2024-10-01 10:41:17 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<vector>
using namespace std;
const int N = 3e5 + 5;
const int M = 5e5 + 5;
int n, qr, m, cnt[N], a[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]);
}
bool flag = 1;
for(int i = 2; i <= m; i++){
if(a[i] < a[i - 1]){
flag = 0;
break;
}
}
if(!flag) printf("No\n");
else printf("Yes\n");
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 11540kb
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 No
result:
wrong answer expected YES, found NO [10th token]