QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#86243#4000. Dynamic ReachabilityfansizheWA 2ms4656kbC++23465b2023-03-09 16:09:582023-03-09 16:12:10

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-09 16:12:10]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:4656kb
  • [2023-03-09 16:09:58]
  • 提交

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: ''