QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#609296 | #8517. Interesting Paths | Capps | WA | 0ms | 3872kb | C++20 | 1.1kb | 2024-10-04 11:52:35 | 2024-10-04 11:52:37 |
Judging History
answer
#include <bits/stdc++.h>
using i64 = long long;
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
int n, m;
std::cin >> n >> m;
std::vector<std::vector<int>> adj(n);
for (int i = 0; i < m; i++) {
int x, y;
std::cin >> x >> y;
x -= 1, y -= 1;
assert(x < y);
adj[x].push_back(y);
}
// for (int x = 0; x < n; x++) {
// for (int y = x + 1; y < n; y++) {
// adj[x].push_back(y);
// }
// }
std::vector<int> vis(n);
vis[n - 1] = 1;
for (int x = n - 1; x >= 0; x--) {
for (int y : adj[x]) {
vis[x] |= vis[y];
}
}
std::vector<int> f(n);
f[0] = 1;
for (int x = 0; x < n; x++) {
for (int y : adj[x]) {
if (vis[y]) {
f[y] += f[x] - 1;
break;
}
}
for (int y : adj[x]) {
f[y] += 1;
}
}
// for (int x = 0; x < n; x++) {
// std::cerr << x + 1 << ' ' << f[x] << '\n';
// }
std::cout << f[n - 1];
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3672kb
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: 0ms
memory: 3576kb
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: 3572kb
input:
2 0
output:
0
result:
ok 1 number(s): "0"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
2 1 1 2
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3872kb
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'