QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#602554#8720. BFS 序 0frs#WA 0ms11540kbC++141.1kb2024-10-01 10:41:162024-10-01 10:41:17

Judging History

你现在查看的是最新测评结果

  • [2024-10-01 10:41:17]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:11540kb
  • [2024-10-01 10:41:16]
  • 提交

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;
}

詳細信息

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]