QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#563234 | #8517. Interesting Paths | ucup-team3931# | WA | 8ms | 32652kb | C++14 | 1.1kb | 2024-09-14 08:21:11 | 2024-09-14 08:21:12 |
Judging History
answer
#include <bits/stdc++.h>
#define eb emplace_back
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
bool Mbe;
const int N = 1e6 + 5;
int n, m, d[N], vs[N];
vector<int> g[N];
pi e[N];
void solve() {
cin >> n >> m;
for (int i = 1, u, v; i <= m; i++)
cin >> u >> v, g[u].eb(v), d[v]++, e[i] = mp(u, v);
queue<int> q; q.push(1);
while (!q.empty()) {
int u = q.front(); q.pop(), vs[u] = 1;
for (int v : g[u]) if (!--d[v]) q.push(v);
}
if (!vs[n]) return cout << 0 << '\n', void();
int c1 = 0, c2 = 0;
for (int i = 1; i <= n; i++) c1 += vs[i];
for (int i = 1; i <= m; i++) c2 += (vs[e[i].fi] && vs[e[i].se]);
cout << c2 - c1 + 2 << '\n';
}
bool Med;
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cerr << (&Mbe - &Med) / 1048576.0 << " MB\n";
#ifdef FILE
freopen(".in", "r", stdin);
freopen(".out", "w", stdout);
#endif
int T = 1;
// cin >> T;
while (T--) solve();
cerr << (int)(1e3 * clock() / CLOCKS_PER_SEC) << " ms\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 8ms
memory: 30740kb
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: 4ms
memory: 30568kb
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: 30440kb
input:
2 0
output:
0
result:
ok 1 number(s): "0"
Test #4:
score: 0
Accepted
time: 0ms
memory: 30732kb
input:
2 1 1 2
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: 0
Accepted
time: 0ms
memory: 30628kb
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: 6ms
memory: 32652kb
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:
0
result:
wrong answer 1st numbers differ - expected: '19', found: '0'