QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#556091#8517. Interesting PathsDjangle162857#WA 1ms10224kbC++14821b2024-09-10 14:59:232024-09-10 14:59:25

Judging History

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

  • [2024-09-10 14:59:25]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:10224kb
  • [2024-09-10 14:59:23]
  • 提交

answer

#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<vector>
#include<cstdio>
#include<queue>
using namespace std;

const int N=1000010;
const int M=1000010;
int n,m,ans;

struct Graph{
	int tot,head[M],suiv[N],ver[N],ind[N],vis[N];

	inline void lnk(int x,int y)
	{
		ver[++tot]=y;
		suiv[tot]=head[x];
		head[x]=tot;
		ind[y]++;
	}

	inline void topo()
	{
		queue<int>q;
		q.push(1);
		while(q.size())
		{
			int x=q.front();q.pop();
			for(int i=head[x];i;i=suiv[i])
			{
				int y=ver[i];
				if(vis[x]&&vis[y])ans++;
				else vis[x]=vis[y]=1;
				if(!--ind[y])q.push(y);
			}
		}
	}
}e;

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1,x,y;i<=m;i++)
		scanf("%d%d",&x,&y),e.lnk(x,y);
	e.topo();
	if(!e.vis[n])puts("0");
	else printf("%d\n",ans+1);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 9928kb

input:

5 7
1 3
3 5
1 2
2 3
3 4
4 5
2 4

output:

4

result:

ok 1 number(s): "4"

Test #2:

score: 0
Accepted
time: 1ms
memory: 9732kb

input:

5 3
1 3
2 3
2 5

output:

0

result:

ok 1 number(s): "0"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3672kb

input:

2 0

output:

0

result:

ok 1 number(s): "0"

Test #4:

score: 0
Accepted
time: 0ms
memory: 10176kb

input:

2 1
1 2

output:

1

result:

ok 1 number(s): "1"

Test #5:

score: 0
Accepted
time: 1ms
memory: 9820kb

input:

10 20
2 8
5 8
4 8
3 10
3 7
2 7
2 5
1 7
6 9
6 10
2 4
5 9
2 10
3 9
7 8
4 10
3 6
2 3
5 7
6 8

output:

0

result:

ok 1 number(s): "0"

Test #6:

score: -100
Wrong Answer
time: 1ms
memory: 10224kb

input:

10 30
8 9
1 5
3 6
4 6
4 7
6 9
3 5
5 6
3 8
1 4
3 4
7 8
2 4
4 5
1 8
6 10
2 10
9 10
1 2
8 10
2 7
2 8
2 5
7 9
2 6
4 8
1 7
1 6
7 10
4 9

output:

6

result:

wrong answer 1st numbers differ - expected: '19', found: '6'