# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
909136 |
2024-01-17T05:43:47 Z |
adhityamv |
Game (APIO22_game) |
C++17 |
|
4000 ms |
44764 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pii pair<int,int>
#define fi first
#define se second
vector<vector<int>> edges;
vector<vector<int>> redges;
vector<int> minreach;
vector<int> maxreturn;
int n,k;
void init(int N,int K){
n=N;
k=K;
for(int i=0;i<n;i++){
edges.push_back({});
redges.push_back({});
}
for(int i=0;i<k;i++){
minreach.push_back(i);
maxreturn.push_back(i);
}
for(int i=k;i<n;i++){
minreach.push_back(k);
maxreturn.push_back(-1);
}
}
bool dfs(int u){
bool ans=true;
if((maxreturn[u]>minreach[u]) || (maxreturn[u]==minreach[u] && u>=k)) ans=false;
for(int v:edges[u]){
if(maxreturn[v]<maxreturn[u]){
maxreturn[v]=maxreturn[u];
if(!dfs(v)) ans=false;;
}
}
return ans;
}
bool rdfs(int u){
bool ans=true;
if((maxreturn[u]>minreach[u]) || (maxreturn[u]==minreach[u] && u>=k)) ans=false;
for(int v:redges[u]){
if(minreach[v]>minreach[u]){
minreach[v]=minreach[u];
if(!dfs(v)) ans=false;;
}
}
return ans;
}
int add_teleporter(int u,int v){
if(u==v){
if(u>=k) return 0;
return 1;
}
edges[u].push_back(v);
redges[v].push_back(u);
if(maxreturn[v]<maxreturn[u]){
maxreturn[v]=maxreturn[u];
if(!dfs(v)) return 1;
}
if(minreach[u]>minreach[v]){
minreach[u]=minreach[v];
if(!rdfs(u)) return 1;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
500 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
492 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
344 KB |
Output is correct |
18 |
Correct |
1 ms |
596 KB |
Output is correct |
19 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
500 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
492 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
344 KB |
Output is correct |
18 |
Correct |
1 ms |
596 KB |
Output is correct |
19 |
Correct |
1 ms |
344 KB |
Output is correct |
20 |
Correct |
1 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 |
3 ms |
600 KB |
Output is correct |
26 |
Correct |
3 ms |
600 KB |
Output is correct |
27 |
Correct |
2 ms |
600 KB |
Output is correct |
28 |
Correct |
1 ms |
344 KB |
Output is correct |
29 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
500 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
492 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
344 KB |
Output is correct |
18 |
Correct |
1 ms |
596 KB |
Output is correct |
19 |
Correct |
1 ms |
344 KB |
Output is correct |
20 |
Correct |
1 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 |
3 ms |
600 KB |
Output is correct |
26 |
Correct |
3 ms |
600 KB |
Output is correct |
27 |
Correct |
2 ms |
600 KB |
Output is correct |
28 |
Correct |
1 ms |
344 KB |
Output is correct |
29 |
Correct |
1 ms |
344 KB |
Output is correct |
30 |
Correct |
14 ms |
3656 KB |
Output is correct |
31 |
Correct |
4 ms |
2376 KB |
Output is correct |
32 |
Correct |
19 ms |
5068 KB |
Output is correct |
33 |
Correct |
22 ms |
4192 KB |
Output is correct |
34 |
Correct |
508 ms |
5416 KB |
Output is correct |
35 |
Correct |
173 ms |
5012 KB |
Output is correct |
36 |
Correct |
22 ms |
4168 KB |
Output is correct |
37 |
Correct |
20 ms |
4168 KB |
Output is correct |
38 |
Correct |
19 ms |
3912 KB |
Output is correct |
39 |
Correct |
27 ms |
4100 KB |
Output is correct |
40 |
Correct |
410 ms |
5704 KB |
Output is correct |
41 |
Correct |
92 ms |
4220 KB |
Output is correct |
42 |
Correct |
55 ms |
3952 KB |
Output is correct |
43 |
Correct |
26 ms |
5964 KB |
Output is correct |
44 |
Correct |
278 ms |
5372 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
500 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
492 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
344 KB |
Output is correct |
18 |
Correct |
1 ms |
596 KB |
Output is correct |
19 |
Correct |
1 ms |
344 KB |
Output is correct |
20 |
Correct |
1 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 |
3 ms |
600 KB |
Output is correct |
26 |
Correct |
3 ms |
600 KB |
Output is correct |
27 |
Correct |
2 ms |
600 KB |
Output is correct |
28 |
Correct |
1 ms |
344 KB |
Output is correct |
29 |
Correct |
1 ms |
344 KB |
Output is correct |
30 |
Correct |
14 ms |
3656 KB |
Output is correct |
31 |
Correct |
4 ms |
2376 KB |
Output is correct |
32 |
Correct |
19 ms |
5068 KB |
Output is correct |
33 |
Correct |
22 ms |
4192 KB |
Output is correct |
34 |
Correct |
508 ms |
5416 KB |
Output is correct |
35 |
Correct |
173 ms |
5012 KB |
Output is correct |
36 |
Correct |
22 ms |
4168 KB |
Output is correct |
37 |
Correct |
20 ms |
4168 KB |
Output is correct |
38 |
Correct |
19 ms |
3912 KB |
Output is correct |
39 |
Correct |
27 ms |
4100 KB |
Output is correct |
40 |
Correct |
410 ms |
5704 KB |
Output is correct |
41 |
Correct |
92 ms |
4220 KB |
Output is correct |
42 |
Correct |
55 ms |
3952 KB |
Output is correct |
43 |
Correct |
26 ms |
5964 KB |
Output is correct |
44 |
Correct |
278 ms |
5372 KB |
Output is correct |
45 |
Correct |
234 ms |
33536 KB |
Output is correct |
46 |
Correct |
22 ms |
22316 KB |
Output is correct |
47 |
Correct |
20 ms |
21700 KB |
Output is correct |
48 |
Correct |
383 ms |
44764 KB |
Output is correct |
49 |
Correct |
243 ms |
38812 KB |
Output is correct |
50 |
Execution timed out |
4057 ms |
36320 KB |
Time limit exceeded |
51 |
Halted |
0 ms |
0 KB |
- |