QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#86243 | #4000. Dynamic Reachability | fansizhe | WA | 2ms | 4656kb | C++23 | 465b | 2023-03-09 16:09:58 | 2023-03-09 16:12:10 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int n,m,q;
vector<int> edge[50005];
int deg[50005];
queue<int> que;
int main(){
scanf("%d%d%d",&n,&m,&q);
for(int i=1;i<=m;i++){
int x,y;scanf("%d%d",&x,&y);
edge[x].push_back(y);
deg[y]++;
}
for(int i=1;i<=n;i++)if(!deg[i])que.push(i);
while(!que.empty()){
int x=que.front();que.pop();
for(int y:edge[x])if(!--deg[y])que.push(y);
}
for(int i=1;i<=n;i++)assert(!deg[i]);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 4656kb
input:
5 6 7 1 2 1 3 2 4 3 4 3 5 4 5 2 1 5 2 2 3 1 3 1 4 2 1 4 1 3 2 1 5
output:
result:
wrong answer 1st lines differ - expected: 'YES', found: ''