QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#779599#8517. Interesting PathsguanzyWA 0ms31136kbC++14475b2024-11-24 20:13:532024-11-24 20:13:53

Judging History

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

  • [2024-11-24 20:13:53]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:31136kb
  • [2024-11-24 20:13:53]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int n,m,f[1000010],ans;
vector<int> G[1000010]; 
int dfs(int u){
	if(f[u]!=-1) return f[u];
	f[u]=0;
	for(int i=0;i<G[u].size();i++){
		int v=G[u][i];
		if(f[v]!=-1) ans+=f[v],f[u]|=f[v];
		else f[u]|=dfs(v),ans++;
		
	}
	return f[u];
}
int main(){
	cin>>n>>m;
	memset(f,-1,sizeof(f));
	for(int i=1;i<=m;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		G[u].push_back(v);
	}
	dfs(1);
	cout<<ans;
	return 0;
}

详细

Test #1:

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

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: -100
Wrong Answer
time: 0ms
memory: 31136kb

input:

5 3
1 3
2 3
2 5

output:

1

result:

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