QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#557912 | #8517. Interesting Paths | FDUdululu | WA | 3ms | 28552kb | C++14 | 795b | 2024-09-11 12:16:32 | 2024-09-11 12:16:32 |
Judging History
answer
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
const int N = 1e6 + 5;
int n, m;
vector<int> son[N];
ll f[N];
ll dfs(int x) {
if (f[x] != -1)
return 1;
f[x] = 0;
for (auto y : son[x])
f[x] += dfs(y);
return f[x];
}
void solve() {
cin >> n >> m;
for (int i = 1; i <= m; i++) {
int u, v;
cin >> u >> v;
son[v].push_back(u);
}
for (int i = 1; i <= n; i++)
f[i] = -1;
f[1] = 1;
cout << dfs(n) << "\n";
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int T = 1;
// cin >> T;
while (T--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 28044kb
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: 3ms
memory: 28552kb
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: 27268kb
input:
2 0
output:
0
result:
ok 1 number(s): "0"
Test #4:
score: 0
Accepted
time: 3ms
memory: 28200kb
input:
2 1 1 2
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: -100
Wrong Answer
time: 3ms
memory: 27984kb
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:
3
result:
wrong answer 1st numbers differ - expected: '0', found: '3'