# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
856745 | 2023-10-04T12:14:48 Z | hariaakas646 | Bitaro’s Party (JOI18_bitaro) | C++17 | 398 ms | 261072 KB |
#include <bits/stdc++.h> using namespace std; #define scd(t) scanf("%d", &t) #define sclld(t) scanf("%lld", &t) #define forr(i, j, k) for (int i = j; i < k; i++) #define frange(i, j) forr(i, 0, j) #define all(cont) cont.begin(), cont.end() #define mp make_pair #define pb push_back #define f first #define s second typedef long long int lli; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<bool> vb; typedef vector<lli> vll; typedef vector<string> vs; typedef vector<pii> vii; typedef vector<vi> vvi; typedef map<int, int> mpii; typedef set<int> seti; typedef multiset<int> mseti; typedef long double ld; void usaco() { freopen("/media/hariaakash646/785EF1075EF0BF46/CompetitiveProgramming/input.in", "r", stdin); // freopen("disrupt.in", "r", stdin); // freopen("disrupt.out", "w", stdout); } int main() { // usaco(); int n, m, q; scd(n); scd(m); scd(q); vvi graph(n+1); frange(i, m) { int a, b; scd(a); scd(b); graph[b].pb(a); } int sq = 320; vector<vii> topo(n+1, vii(sq+1, mp(-1e9, -1))); forr(i, 1, n+1) { vi cnt(graph[i].size()); // printf("%d\n", i); frange(j, sq+1) { int ma = -1; int mid = -1; int me = -1; frange(k, graph[i].size()) { int e = graph[i][k]; // printf("%d\n", e); if(topo[e][cnt[k]].f + 1 > 0 && topo[e][cnt[k]].f + 1 > ma) { ma = topo[e][cnt[k]].f + 1; mid = topo[e][cnt[k]].s; me = k; } } if(mid == -1) { topo[i][j] = mp(0, i); // printf("%d %d %d %d\n", i, j, 0, i); break; } else { cnt[me]++; topo[i][j] = mp(ma, mid); // printf("%d %d %d %d\n", i, j, ma, mid); } } } vb busy(n+1); frange(_, q) { int t, y; scd(t); scd(y); vi vec; frange(i, y) { int a; scd(a); vec.pb(a); busy[a] = true; } if(y >= sq-1) { vi topo2(n+1, -1e9); forr(i, 1, n+1) { if(!busy[i]) { topo2[i] = 0; } for(auto e : graph[i]) { topo2[i] = max(topo2[e]+1, topo2[i]); } } if(topo2[t] >= 0) printf("%d\n", topo2[t]); else printf("-1\n"); } else { frange(i, sq+2) { if(i==sq+1 || topo[t][i].s == -1) { printf("%d\n", -1); break; } else { if(!busy[topo[t][i].s]) { printf("%d\n", topo[t][i].f); break; } } } } for(auto e : vec) busy[e] = false; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 3 ms | 2908 KB | Output is correct |
6 | Correct | 3 ms | 2908 KB | Output is correct |
7 | Correct | 3 ms | 2908 KB | Output is correct |
8 | Correct | 3 ms | 3048 KB | Output is correct |
9 | Correct | 3 ms | 2908 KB | Output is correct |
10 | Correct | 3 ms | 3036 KB | Output is correct |
11 | Correct | 3 ms | 2908 KB | Output is correct |
12 | Correct | 2 ms | 2908 KB | Output is correct |
13 | Correct | 3 ms | 2908 KB | Output is correct |
14 | Correct | 3 ms | 2908 KB | Output is correct |
15 | Correct | 2 ms | 2908 KB | Output is correct |
16 | Correct | 3 ms | 2908 KB | Output is correct |
17 | Correct | 3 ms | 2908 KB | Output is correct |
18 | Correct | 2 ms | 2908 KB | Output is correct |
19 | Correct | 3 ms | 2904 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 3 ms | 2908 KB | Output is correct |
6 | Correct | 3 ms | 2908 KB | Output is correct |
7 | Correct | 3 ms | 2908 KB | Output is correct |
8 | Correct | 3 ms | 3048 KB | Output is correct |
9 | Correct | 3 ms | 2908 KB | Output is correct |
10 | Correct | 3 ms | 3036 KB | Output is correct |
11 | Correct | 3 ms | 2908 KB | Output is correct |
12 | Correct | 2 ms | 2908 KB | Output is correct |
13 | Correct | 3 ms | 2908 KB | Output is correct |
14 | Correct | 3 ms | 2908 KB | Output is correct |
15 | Correct | 2 ms | 2908 KB | Output is correct |
16 | Correct | 3 ms | 2908 KB | Output is correct |
17 | Correct | 3 ms | 2908 KB | Output is correct |
18 | Correct | 2 ms | 2908 KB | Output is correct |
19 | Correct | 3 ms | 2904 KB | Output is correct |
20 | Correct | 116 ms | 4188 KB | Output is correct |
21 | Correct | 110 ms | 4236 KB | Output is correct |
22 | Correct | 136 ms | 4268 KB | Output is correct |
23 | Correct | 125 ms | 4432 KB | Output is correct |
24 | Correct | 300 ms | 260612 KB | Output is correct |
25 | Correct | 303 ms | 260604 KB | Output is correct |
26 | Correct | 333 ms | 260608 KB | Output is correct |
27 | Correct | 280 ms | 261036 KB | Output is correct |
28 | Correct | 288 ms | 260980 KB | Output is correct |
29 | Correct | 284 ms | 261028 KB | Output is correct |
30 | Correct | 291 ms | 261032 KB | Output is correct |
31 | Correct | 317 ms | 261072 KB | Output is correct |
32 | Correct | 292 ms | 261012 KB | Output is correct |
33 | Correct | 258 ms | 260548 KB | Output is correct |
34 | Correct | 254 ms | 260528 KB | Output is correct |
35 | Correct | 267 ms | 260560 KB | Output is correct |
36 | Correct | 283 ms | 260584 KB | Output is correct |
37 | Correct | 301 ms | 260564 KB | Output is correct |
38 | Correct | 281 ms | 260560 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 3 ms | 2908 KB | Output is correct |
6 | Correct | 3 ms | 2908 KB | Output is correct |
7 | Correct | 3 ms | 2908 KB | Output is correct |
8 | Correct | 3 ms | 3048 KB | Output is correct |
9 | Correct | 3 ms | 2908 KB | Output is correct |
10 | Correct | 3 ms | 3036 KB | Output is correct |
11 | Correct | 3 ms | 2908 KB | Output is correct |
12 | Correct | 2 ms | 2908 KB | Output is correct |
13 | Correct | 3 ms | 2908 KB | Output is correct |
14 | Correct | 3 ms | 2908 KB | Output is correct |
15 | Correct | 2 ms | 2908 KB | Output is correct |
16 | Correct | 3 ms | 2908 KB | Output is correct |
17 | Correct | 3 ms | 2908 KB | Output is correct |
18 | Correct | 2 ms | 2908 KB | Output is correct |
19 | Correct | 3 ms | 2904 KB | Output is correct |
20 | Correct | 116 ms | 4188 KB | Output is correct |
21 | Correct | 110 ms | 4236 KB | Output is correct |
22 | Correct | 136 ms | 4268 KB | Output is correct |
23 | Correct | 125 ms | 4432 KB | Output is correct |
24 | Correct | 300 ms | 260612 KB | Output is correct |
25 | Correct | 303 ms | 260604 KB | Output is correct |
26 | Correct | 333 ms | 260608 KB | Output is correct |
27 | Correct | 280 ms | 261036 KB | Output is correct |
28 | Correct | 288 ms | 260980 KB | Output is correct |
29 | Correct | 284 ms | 261028 KB | Output is correct |
30 | Correct | 291 ms | 261032 KB | Output is correct |
31 | Correct | 317 ms | 261072 KB | Output is correct |
32 | Correct | 292 ms | 261012 KB | Output is correct |
33 | Correct | 258 ms | 260548 KB | Output is correct |
34 | Correct | 254 ms | 260528 KB | Output is correct |
35 | Correct | 267 ms | 260560 KB | Output is correct |
36 | Correct | 283 ms | 260584 KB | Output is correct |
37 | Correct | 301 ms | 260564 KB | Output is correct |
38 | Correct | 281 ms | 260560 KB | Output is correct |
39 | Correct | 340 ms | 260180 KB | Output is correct |
40 | Correct | 304 ms | 259920 KB | Output is correct |
41 | Correct | 304 ms | 259960 KB | Output is correct |
42 | Correct | 398 ms | 260396 KB | Output is correct |
43 | Correct | 311 ms | 260432 KB | Output is correct |
44 | Incorrect | 150 ms | 4568 KB | Output isn't correct |
45 | Halted | 0 ms | 0 KB | - |