QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#779599 | #8517. Interesting Paths | guanzy | WA | 0ms | 31136kb | C++14 | 475b | 2024-11-24 20:13:53 | 2024-11-24 20:13:53 |
Judging History
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'