# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
47783 | 2018-05-07T08:30:38 Z | Talant | Bitaro’s Party (JOI18_bitaro) | C++14 | 2000 ms | 12612 KB |
#include <bits/stdc++.h> #define mk make_pair #define sc second #define fr first #define pb emplace_back #define all(s) s.begin(), s.end() #define sz(s) ( (int)s.size() ) #define Scan(a) scanf ("%I64d", &a) #define scan(a) scanf ("%d", &a) using namespace std; const int inf = (int)1e9 + 7; const int N = (int)3e5 + 7; int n,m,qy; int l,r; int t,y,x; int d[N],u[N]; int ans = -1; int cnt; vector <int> g[N]; priority_queue<pair<int,int> > q; void djk(int v) { for (int i = 1; i <= n; i ++) d[i] = -inf; d[v] = 0; q.push({0,v}); while (!q.empty()) { int v = q.top().sc,cur = q.top().fr; q.pop(); if (!u[v]) ans = max(ans,d[v]); if (cur < d[v]) continue; for (auto to : g[v]) { if (d[v] + 1 > d[to]) { d[to] = d[v] + 1; q.push({d[to],to}); } cnt ++; } cnt ++; if (cnt > (int)1e8) { cout << ans << endl; exit(0); } } } main () { scan(n);scan(m);scan(qy); for (int i = 1; i <= m; i ++) { scan(l);scan(r); g[r].pb(l); } scan(t);scan(y); if (y == n) { cout << "-1"; return 0; } for (int i = 1; i <= y; i ++) { scan(x); u[x] = 1; } djk(t); printf("%d\n", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 7416 KB | Output is correct |
2 | Correct | 9 ms | 7548 KB | Output is correct |
3 | Correct | 10 ms | 7548 KB | Output is correct |
4 | Correct | 10 ms | 7548 KB | Output is correct |
5 | Correct | 11 ms | 7548 KB | Output is correct |
6 | Correct | 10 ms | 7556 KB | Output is correct |
7 | Correct | 10 ms | 7632 KB | Output is correct |
8 | Correct | 11 ms | 7632 KB | Output is correct |
9 | Correct | 10 ms | 7632 KB | Output is correct |
10 | Correct | 9 ms | 7632 KB | Output is correct |
11 | Correct | 9 ms | 7660 KB | Output is correct |
12 | Correct | 9 ms | 7660 KB | Output is correct |
13 | Correct | 11 ms | 7660 KB | Output is correct |
14 | Correct | 11 ms | 7660 KB | Output is correct |
15 | Correct | 11 ms | 7660 KB | Output is correct |
16 | Correct | 11 ms | 7664 KB | Output is correct |
17 | Correct | 11 ms | 7664 KB | Output is correct |
18 | Correct | 10 ms | 7664 KB | Output is correct |
19 | Correct | 11 ms | 7664 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 7416 KB | Output is correct |
2 | Correct | 9 ms | 7548 KB | Output is correct |
3 | Correct | 10 ms | 7548 KB | Output is correct |
4 | Correct | 10 ms | 7548 KB | Output is correct |
5 | Correct | 11 ms | 7548 KB | Output is correct |
6 | Correct | 10 ms | 7556 KB | Output is correct |
7 | Correct | 10 ms | 7632 KB | Output is correct |
8 | Correct | 11 ms | 7632 KB | Output is correct |
9 | Correct | 10 ms | 7632 KB | Output is correct |
10 | Correct | 9 ms | 7632 KB | Output is correct |
11 | Correct | 9 ms | 7660 KB | Output is correct |
12 | Correct | 9 ms | 7660 KB | Output is correct |
13 | Correct | 11 ms | 7660 KB | Output is correct |
14 | Correct | 11 ms | 7660 KB | Output is correct |
15 | Correct | 11 ms | 7660 KB | Output is correct |
16 | Correct | 11 ms | 7664 KB | Output is correct |
17 | Correct | 11 ms | 7664 KB | Output is correct |
18 | Correct | 10 ms | 7664 KB | Output is correct |
19 | Correct | 11 ms | 7664 KB | Output is correct |
20 | Correct | 80 ms | 9448 KB | Output is correct |
21 | Correct | 72 ms | 9448 KB | Output is correct |
22 | Correct | 98 ms | 9952 KB | Output is correct |
23 | Correct | 65 ms | 9952 KB | Output is correct |
24 | Correct | 140 ms | 11116 KB | Output is correct |
25 | Correct | 108 ms | 11168 KB | Output is correct |
26 | Correct | 136 ms | 11168 KB | Output is correct |
27 | Correct | 144 ms | 12392 KB | Output is correct |
28 | Correct | 131 ms | 12392 KB | Output is correct |
29 | Correct | 130 ms | 12612 KB | Output is correct |
30 | Correct | 108 ms | 12612 KB | Output is correct |
31 | Correct | 110 ms | 12612 KB | Output is correct |
32 | Correct | 110 ms | 12612 KB | Output is correct |
33 | Correct | 95 ms | 12612 KB | Output is correct |
34 | Correct | 105 ms | 12612 KB | Output is correct |
35 | Correct | 98 ms | 12612 KB | Output is correct |
36 | Execution timed out | 2082 ms | 12612 KB | Time limit exceeded |
37 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 7416 KB | Output is correct |
2 | Correct | 9 ms | 7548 KB | Output is correct |
3 | Correct | 10 ms | 7548 KB | Output is correct |
4 | Correct | 10 ms | 7548 KB | Output is correct |
5 | Correct | 11 ms | 7548 KB | Output is correct |
6 | Correct | 10 ms | 7556 KB | Output is correct |
7 | Correct | 10 ms | 7632 KB | Output is correct |
8 | Correct | 11 ms | 7632 KB | Output is correct |
9 | Correct | 10 ms | 7632 KB | Output is correct |
10 | Correct | 9 ms | 7632 KB | Output is correct |
11 | Correct | 9 ms | 7660 KB | Output is correct |
12 | Correct | 9 ms | 7660 KB | Output is correct |
13 | Correct | 11 ms | 7660 KB | Output is correct |
14 | Correct | 11 ms | 7660 KB | Output is correct |
15 | Correct | 11 ms | 7660 KB | Output is correct |
16 | Correct | 11 ms | 7664 KB | Output is correct |
17 | Correct | 11 ms | 7664 KB | Output is correct |
18 | Correct | 10 ms | 7664 KB | Output is correct |
19 | Correct | 11 ms | 7664 KB | Output is correct |
20 | Correct | 80 ms | 9448 KB | Output is correct |
21 | Correct | 72 ms | 9448 KB | Output is correct |
22 | Correct | 98 ms | 9952 KB | Output is correct |
23 | Correct | 65 ms | 9952 KB | Output is correct |
24 | Correct | 140 ms | 11116 KB | Output is correct |
25 | Correct | 108 ms | 11168 KB | Output is correct |
26 | Correct | 136 ms | 11168 KB | Output is correct |
27 | Correct | 144 ms | 12392 KB | Output is correct |
28 | Correct | 131 ms | 12392 KB | Output is correct |
29 | Correct | 130 ms | 12612 KB | Output is correct |
30 | Correct | 108 ms | 12612 KB | Output is correct |
31 | Correct | 110 ms | 12612 KB | Output is correct |
32 | Correct | 110 ms | 12612 KB | Output is correct |
33 | Correct | 95 ms | 12612 KB | Output is correct |
34 | Correct | 105 ms | 12612 KB | Output is correct |
35 | Correct | 98 ms | 12612 KB | Output is correct |
36 | Execution timed out | 2082 ms | 12612 KB | Time limit exceeded |
37 | Halted | 0 ms | 0 KB | - |