# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1088700 |
2024-09-14T19:55:20 Z |
Math4Life2020 |
Game (APIO22_game) |
C++17 |
|
4000 ms |
18124 KB |
#include <bits/stdc++.h>
using namespace std;
using ll = int; using pii = pair<ll,ll>;
ll N,K;
const ll INF = 1e9;
vector<vector<ll>> f; //forward edges
vector<ll> mc; //min color
void init(int N1, int K1) {
N=N1; K=K1;
f.clear(); mc.clear();
vector<int> vb;
for (ll i=0;i<N;i++) {
f.push_back(vb);
mc.push_back(-INF);
}
for (ll k=0;k<K;k++){
mc[k]=k;
}
}
int add_teleporter(int u, int v) {
if (u<K && v<K) {
if (v<=u) {
return 1;
} else {
return 0;
}
}
if (u==v) {
return 0;
}
if (v<K && mc[u]>=v) {
return 1;
}
//cout << "updating u,v="<<u<<","<<v<<"\n";
f[u].push_back(v);
if (mc[u]<=mc[v]) {
return 0;
}
stack<int> s;
ll val = mc[u];
s.push(v);
while (!s.empty()) {
ll x = s.top(); s.pop();
if (x<K) {
if (x<=val) {
return 1;
}
} else {
if (mc[x]<val) {
//cout << "processD: x="<<x<<"\n";
mc[x]=val;
for (ll y: f[x]) {
s.push(y);
}
}
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
596 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
596 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
0 ms |
344 KB |
Output is correct |
17 |
Correct |
0 ms |
344 KB |
Output is correct |
18 |
Correct |
0 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
596 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
0 ms |
344 KB |
Output is correct |
17 |
Correct |
0 ms |
344 KB |
Output is correct |
18 |
Correct |
0 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
344 KB |
Output is correct |
20 |
Correct |
0 ms |
344 KB |
Output is correct |
21 |
Correct |
1 ms |
344 KB |
Output is correct |
22 |
Correct |
1 ms |
344 KB |
Output is correct |
23 |
Correct |
1 ms |
344 KB |
Output is correct |
24 |
Correct |
2 ms |
344 KB |
Output is correct |
25 |
Correct |
2 ms |
344 KB |
Output is correct |
26 |
Correct |
2 ms |
344 KB |
Output is correct |
27 |
Correct |
1 ms |
344 KB |
Output is correct |
28 |
Correct |
1 ms |
388 KB |
Output is correct |
29 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
596 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
0 ms |
344 KB |
Output is correct |
17 |
Correct |
0 ms |
344 KB |
Output is correct |
18 |
Correct |
0 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
344 KB |
Output is correct |
20 |
Correct |
0 ms |
344 KB |
Output is correct |
21 |
Correct |
1 ms |
344 KB |
Output is correct |
22 |
Correct |
1 ms |
344 KB |
Output is correct |
23 |
Correct |
1 ms |
344 KB |
Output is correct |
24 |
Correct |
2 ms |
344 KB |
Output is correct |
25 |
Correct |
2 ms |
344 KB |
Output is correct |
26 |
Correct |
2 ms |
344 KB |
Output is correct |
27 |
Correct |
1 ms |
344 KB |
Output is correct |
28 |
Correct |
1 ms |
388 KB |
Output is correct |
29 |
Correct |
1 ms |
344 KB |
Output is correct |
30 |
Correct |
8 ms |
2036 KB |
Output is correct |
31 |
Correct |
2 ms |
1268 KB |
Output is correct |
32 |
Correct |
9 ms |
2036 KB |
Output is correct |
33 |
Correct |
8 ms |
2092 KB |
Output is correct |
34 |
Correct |
518 ms |
2372 KB |
Output is correct |
35 |
Correct |
181 ms |
2036 KB |
Output is correct |
36 |
Correct |
16 ms |
2292 KB |
Output is correct |
37 |
Correct |
17 ms |
2164 KB |
Output is correct |
38 |
Correct |
13 ms |
1780 KB |
Output is correct |
39 |
Correct |
18 ms |
1808 KB |
Output is correct |
40 |
Correct |
424 ms |
2280 KB |
Output is correct |
41 |
Correct |
80 ms |
2064 KB |
Output is correct |
42 |
Correct |
51 ms |
2028 KB |
Output is correct |
43 |
Correct |
17 ms |
2196 KB |
Output is correct |
44 |
Correct |
276 ms |
2036 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
596 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
0 ms |
344 KB |
Output is correct |
17 |
Correct |
0 ms |
344 KB |
Output is correct |
18 |
Correct |
0 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
344 KB |
Output is correct |
20 |
Correct |
0 ms |
344 KB |
Output is correct |
21 |
Correct |
1 ms |
344 KB |
Output is correct |
22 |
Correct |
1 ms |
344 KB |
Output is correct |
23 |
Correct |
1 ms |
344 KB |
Output is correct |
24 |
Correct |
2 ms |
344 KB |
Output is correct |
25 |
Correct |
2 ms |
344 KB |
Output is correct |
26 |
Correct |
2 ms |
344 KB |
Output is correct |
27 |
Correct |
1 ms |
344 KB |
Output is correct |
28 |
Correct |
1 ms |
388 KB |
Output is correct |
29 |
Correct |
1 ms |
344 KB |
Output is correct |
30 |
Correct |
8 ms |
2036 KB |
Output is correct |
31 |
Correct |
2 ms |
1268 KB |
Output is correct |
32 |
Correct |
9 ms |
2036 KB |
Output is correct |
33 |
Correct |
8 ms |
2092 KB |
Output is correct |
34 |
Correct |
518 ms |
2372 KB |
Output is correct |
35 |
Correct |
181 ms |
2036 KB |
Output is correct |
36 |
Correct |
16 ms |
2292 KB |
Output is correct |
37 |
Correct |
17 ms |
2164 KB |
Output is correct |
38 |
Correct |
13 ms |
1780 KB |
Output is correct |
39 |
Correct |
18 ms |
1808 KB |
Output is correct |
40 |
Correct |
424 ms |
2280 KB |
Output is correct |
41 |
Correct |
80 ms |
2064 KB |
Output is correct |
42 |
Correct |
51 ms |
2028 KB |
Output is correct |
43 |
Correct |
17 ms |
2196 KB |
Output is correct |
44 |
Correct |
276 ms |
2036 KB |
Output is correct |
45 |
Correct |
95 ms |
14560 KB |
Output is correct |
46 |
Correct |
11 ms |
14824 KB |
Output is correct |
47 |
Correct |
11 ms |
14824 KB |
Output is correct |
48 |
Correct |
117 ms |
18124 KB |
Output is correct |
49 |
Correct |
94 ms |
18112 KB |
Output is correct |
50 |
Execution timed out |
4096 ms |
14624 KB |
Time limit exceeded |
51 |
Halted |
0 ms |
0 KB |
- |