# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
982893 |
2024-05-15T01:04:28 Z |
vjudge1 |
Game (APIO22_game) |
C++17 |
|
4000 ms |
36192 KB |
#include "game.h"
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
int K;
int N;
vector<int> mini;
vector<int> maxi;
vector<vector<int>> teapuntan;
vector<vector<int>> apuntas;
void init(int n, int k) {
N=n;
K=k;
mini.resize( n, 1e9);
maxi.resize(n, -1);
teapuntan.resize(n);
apuntas.resize(n);
}
int add_teleporter(int u, int v) {
if(u<K && v<K){
if(u>=v) return 1;
return 0;
}
if(u<K){
queue<int> q;
q.push(v);
vector<bool> visited (N, 0);
while(!q.empty()){
int x=q.front();
q.pop();
if(visited[x]) continue;
visited[x]=true;
if(maxi[x]>=u) continue;
maxi[x]=u;
if(maxi[x]>=mini[x]) return 1;
for(int y: apuntas[x]){
if(visited[y]) continue;
q.push(y);
}
}
}
else if(v<K){
queue<int> q;
q.push(u);
vector<bool> visited(N,0);
while(!q.empty()){
int x=q.front();
q.pop();
if(visited[x]) continue;
visited[x]=true;
if(mini[x]<=v) continue;
mini[x]=v;
if(maxi[x]>=mini[x]) return 1;
for(int y:teapuntan[x]){
if(visited[y]) continue;
q.push(y);
}
}
}
else{
apuntas[u].pb(v);
teapuntan[v].pb(u);
queue<int> q;
q.push(v);
vector<bool> visited1 (N, false);
while(!q.empty()){
int x=q.front();
q.pop();
if(visited1[x]) continue;
visited1[x]=1;
if(maxi[x]>=maxi[u]) continue;
maxi[x]=maxi[u];
if(maxi[x]>=mini[x]) return 1;
for(int y: apuntas[x]){
if(visited1[y]) continue;
q.push(y);
}
}
vector<bool> visited2 (N, 0);
q.push(u);
while(!q.empty()){
int x=q.front();
q.pop();
if(visited2[x]) continue;
visited2[x]=1;
if(mini[x]<=mini[v]) continue;
mini[x]=mini[v];
if(maxi[x]>=mini[x]) return 1;
for(int y:teapuntan[x]){
if(visited2[y]) continue;
q.push(y);
}
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 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 |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 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 |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
596 KB |
Output is correct |
11 |
Correct |
1 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 |
596 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 |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 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 |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
596 KB |
Output is correct |
11 |
Correct |
1 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 |
596 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 |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
344 KB |
Output is correct |
20 |
Correct |
1 ms |
344 KB |
Output is correct |
21 |
Correct |
0 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 |
3 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 |
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 |
0 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 |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
596 KB |
Output is correct |
11 |
Correct |
1 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 |
596 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 |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
344 KB |
Output is correct |
20 |
Correct |
1 ms |
344 KB |
Output is correct |
21 |
Correct |
0 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 |
3 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 |
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 |
23 ms |
3756 KB |
Output is correct |
31 |
Correct |
5 ms |
2392 KB |
Output is correct |
32 |
Correct |
24 ms |
4092 KB |
Output is correct |
33 |
Correct |
25 ms |
4472 KB |
Output is correct |
34 |
Correct |
932 ms |
3928 KB |
Output is correct |
35 |
Correct |
338 ms |
4280 KB |
Output is correct |
36 |
Correct |
42 ms |
4204 KB |
Output is correct |
37 |
Correct |
38 ms |
4808 KB |
Output is correct |
38 |
Correct |
32 ms |
3728 KB |
Output is correct |
39 |
Correct |
30 ms |
3660 KB |
Output is correct |
40 |
Correct |
759 ms |
3944 KB |
Output is correct |
41 |
Correct |
165 ms |
4176 KB |
Output is correct |
42 |
Correct |
107 ms |
3752 KB |
Output is correct |
43 |
Correct |
50 ms |
4252 KB |
Output is correct |
44 |
Correct |
344 ms |
4388 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 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 |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
596 KB |
Output is correct |
11 |
Correct |
1 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 |
596 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 |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
344 KB |
Output is correct |
20 |
Correct |
1 ms |
344 KB |
Output is correct |
21 |
Correct |
0 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 |
3 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 |
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 |
23 ms |
3756 KB |
Output is correct |
31 |
Correct |
5 ms |
2392 KB |
Output is correct |
32 |
Correct |
24 ms |
4092 KB |
Output is correct |
33 |
Correct |
25 ms |
4472 KB |
Output is correct |
34 |
Correct |
932 ms |
3928 KB |
Output is correct |
35 |
Correct |
338 ms |
4280 KB |
Output is correct |
36 |
Correct |
42 ms |
4204 KB |
Output is correct |
37 |
Correct |
38 ms |
4808 KB |
Output is correct |
38 |
Correct |
32 ms |
3728 KB |
Output is correct |
39 |
Correct |
30 ms |
3660 KB |
Output is correct |
40 |
Correct |
759 ms |
3944 KB |
Output is correct |
41 |
Correct |
165 ms |
4176 KB |
Output is correct |
42 |
Correct |
107 ms |
3752 KB |
Output is correct |
43 |
Correct |
50 ms |
4252 KB |
Output is correct |
44 |
Correct |
344 ms |
4388 KB |
Output is correct |
45 |
Correct |
453 ms |
28540 KB |
Output is correct |
46 |
Correct |
16 ms |
17240 KB |
Output is correct |
47 |
Correct |
16 ms |
17308 KB |
Output is correct |
48 |
Correct |
573 ms |
35884 KB |
Output is correct |
49 |
Correct |
525 ms |
36192 KB |
Output is correct |
50 |
Execution timed out |
4059 ms |
26684 KB |
Time limit exceeded |
51 |
Halted |
0 ms |
0 KB |
- |