# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
622987 |
2022-08-04T23:31:49 Z |
Lobo |
Game (APIO22_game) |
C++17 |
|
82 ms |
40892 KB |
#include "game.h"
#include<iostream>
#include<vector>
using namespace std;
#define pb push_back
const int maxn = 5e4+10;
int n, k, dir[maxn][30];
vector<int> g[maxn], gt[maxn];
int ans = 0;
/*
0 -> fora desse nível
1 -> chega em mid
2 -> mid chega em
*/
void call(int a);
void att(int l, int r, int a, int b, int lv);
void call(int a) {
for(auto b : g[a]) {
att(0,k-1,a,b,0);
}
for(auto b : gt[a]) {
att(0,k-1,b,a,0);
}
}
void att(int l, int r, int a, int b, int lv) {
if(l > r) return;
int mid = (l+r)/2;
if(a == mid) {
if(dir[b][lv] == 0) {
dir[b][lv] = 2; //mid chega no b
call(b); //b muda
}
else if(dir[b][lv] == 1) {
ans = 1; // b chega em mid e mid chega em b
}
return;
}
if(b == mid) {
if(dir[a][lv] == 0) {
dir[a][lv] = 1; //a chega em mid
call(a); //a muda
}
else if(dir[a][lv] == 2) {
ans = 1; // mid chega em a e a chega em mid
}
return;
}
if(dir[a][lv] == 0 && dir[b][lv] == 1) {
//b chega em mid, a chega em b -> a chega em mid
dir[a][lv] = 1;
call(a); //a mudou
att(l,mid-1,a,b,lv+1); //os dois tão no L
return;
}
if(dir[a][lv] == 2 && dir[b][lv] == 0) {
//mid chega em a, a chega em b -> mid chega em b
dir[b][lv] = 2;
call(b); //b mudou
att(mid+1,r,a,b,lv+1); //os dois tão no R
return;
}
if(dir[a][lv] == 2 && dir[b][lv] == 1) {
//mid chega em a, a chega em b, b chega em mid -> mid chega em mid
ans = 1;
return;
}
if(dir[a][lv] == 1 && dir[b][lv] == 1) {
att(l,mid-1,a,b,lv+1); //os dois tão no L | BRUTE ASSIM FICA LOG²
return;
}
if(dir[a][lv] == 2 && dir[b][lv] == 2) {
att(mid+1,r,a,b,lv+1);
return;
}
}
void build(int l, int r, int lv) {
if(l > r) return;
int mid = (l+r)/2;
for(int i = l; i < mid; i++) {
dir[i][lv] = 1;
}
for(int i = mid+1; i <= r; i++) {
dir[i][lv] = 2;
}
build(l,mid-1,lv+1);
build(mid+1,r,lv+1);
}
void init(int N, int K) {
n = N;
k = K;
build(0,k-1,0);
}
int add_teleporter(int u, int v) {
g[u].pb(v);
gt[v].pb(u);
if(u == v && u < k) return 1;
att(0,k-1,u,v,0);
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2640 KB |
Output is correct |
2 |
Correct |
1 ms |
2640 KB |
Output is correct |
3 |
Correct |
1 ms |
2640 KB |
Output is correct |
4 |
Correct |
1 ms |
2640 KB |
Output is correct |
5 |
Correct |
1 ms |
2640 KB |
Output is correct |
6 |
Correct |
1 ms |
2640 KB |
Output is correct |
7 |
Correct |
2 ms |
2640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2640 KB |
Output is correct |
2 |
Correct |
1 ms |
2640 KB |
Output is correct |
3 |
Correct |
1 ms |
2640 KB |
Output is correct |
4 |
Correct |
1 ms |
2640 KB |
Output is correct |
5 |
Correct |
1 ms |
2640 KB |
Output is correct |
6 |
Correct |
1 ms |
2640 KB |
Output is correct |
7 |
Correct |
2 ms |
2640 KB |
Output is correct |
8 |
Correct |
2 ms |
2640 KB |
Output is correct |
9 |
Correct |
1 ms |
2640 KB |
Output is correct |
10 |
Correct |
2 ms |
2640 KB |
Output is correct |
11 |
Correct |
1 ms |
2640 KB |
Output is correct |
12 |
Correct |
1 ms |
2640 KB |
Output is correct |
13 |
Correct |
2 ms |
2640 KB |
Output is correct |
14 |
Correct |
1 ms |
2640 KB |
Output is correct |
15 |
Correct |
2 ms |
2640 KB |
Output is correct |
16 |
Correct |
2 ms |
2640 KB |
Output is correct |
17 |
Correct |
2 ms |
2640 KB |
Output is correct |
18 |
Correct |
1 ms |
2640 KB |
Output is correct |
19 |
Correct |
1 ms |
2640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2640 KB |
Output is correct |
2 |
Correct |
1 ms |
2640 KB |
Output is correct |
3 |
Correct |
1 ms |
2640 KB |
Output is correct |
4 |
Correct |
1 ms |
2640 KB |
Output is correct |
5 |
Correct |
1 ms |
2640 KB |
Output is correct |
6 |
Correct |
1 ms |
2640 KB |
Output is correct |
7 |
Correct |
2 ms |
2640 KB |
Output is correct |
8 |
Correct |
2 ms |
2640 KB |
Output is correct |
9 |
Correct |
1 ms |
2640 KB |
Output is correct |
10 |
Correct |
2 ms |
2640 KB |
Output is correct |
11 |
Correct |
1 ms |
2640 KB |
Output is correct |
12 |
Correct |
1 ms |
2640 KB |
Output is correct |
13 |
Correct |
2 ms |
2640 KB |
Output is correct |
14 |
Correct |
1 ms |
2640 KB |
Output is correct |
15 |
Correct |
2 ms |
2640 KB |
Output is correct |
16 |
Correct |
2 ms |
2640 KB |
Output is correct |
17 |
Correct |
2 ms |
2640 KB |
Output is correct |
18 |
Correct |
1 ms |
2640 KB |
Output is correct |
19 |
Correct |
1 ms |
2640 KB |
Output is correct |
20 |
Correct |
2 ms |
2800 KB |
Output is correct |
21 |
Correct |
2 ms |
2640 KB |
Output is correct |
22 |
Correct |
2 ms |
3004 KB |
Output is correct |
23 |
Correct |
2 ms |
2768 KB |
Output is correct |
24 |
Correct |
2 ms |
2896 KB |
Output is correct |
25 |
Correct |
4 ms |
2896 KB |
Output is correct |
26 |
Correct |
6 ms |
2768 KB |
Output is correct |
27 |
Correct |
4 ms |
2768 KB |
Output is correct |
28 |
Correct |
3 ms |
3060 KB |
Output is correct |
29 |
Correct |
3 ms |
3024 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2640 KB |
Output is correct |
2 |
Correct |
1 ms |
2640 KB |
Output is correct |
3 |
Correct |
1 ms |
2640 KB |
Output is correct |
4 |
Correct |
1 ms |
2640 KB |
Output is correct |
5 |
Correct |
1 ms |
2640 KB |
Output is correct |
6 |
Correct |
1 ms |
2640 KB |
Output is correct |
7 |
Correct |
2 ms |
2640 KB |
Output is correct |
8 |
Correct |
2 ms |
2640 KB |
Output is correct |
9 |
Correct |
1 ms |
2640 KB |
Output is correct |
10 |
Correct |
2 ms |
2640 KB |
Output is correct |
11 |
Correct |
1 ms |
2640 KB |
Output is correct |
12 |
Correct |
1 ms |
2640 KB |
Output is correct |
13 |
Correct |
2 ms |
2640 KB |
Output is correct |
14 |
Correct |
1 ms |
2640 KB |
Output is correct |
15 |
Correct |
2 ms |
2640 KB |
Output is correct |
16 |
Correct |
2 ms |
2640 KB |
Output is correct |
17 |
Correct |
2 ms |
2640 KB |
Output is correct |
18 |
Correct |
1 ms |
2640 KB |
Output is correct |
19 |
Correct |
1 ms |
2640 KB |
Output is correct |
20 |
Correct |
2 ms |
2800 KB |
Output is correct |
21 |
Correct |
2 ms |
2640 KB |
Output is correct |
22 |
Correct |
2 ms |
3004 KB |
Output is correct |
23 |
Correct |
2 ms |
2768 KB |
Output is correct |
24 |
Correct |
2 ms |
2896 KB |
Output is correct |
25 |
Correct |
4 ms |
2896 KB |
Output is correct |
26 |
Correct |
6 ms |
2768 KB |
Output is correct |
27 |
Correct |
4 ms |
2768 KB |
Output is correct |
28 |
Correct |
3 ms |
3060 KB |
Output is correct |
29 |
Correct |
3 ms |
3024 KB |
Output is correct |
30 |
Correct |
18 ms |
6596 KB |
Output is correct |
31 |
Correct |
8 ms |
4048 KB |
Output is correct |
32 |
Correct |
43 ms |
21832 KB |
Output is correct |
33 |
Correct |
22 ms |
8140 KB |
Output is correct |
34 |
Correct |
82 ms |
35156 KB |
Output is correct |
35 |
Correct |
71 ms |
11092 KB |
Output is correct |
36 |
Correct |
52 ms |
8256 KB |
Output is correct |
37 |
Correct |
55 ms |
8008 KB |
Output is correct |
38 |
Correct |
32 ms |
7764 KB |
Output is correct |
39 |
Correct |
39 ms |
7828 KB |
Output is correct |
40 |
Correct |
76 ms |
40892 KB |
Output is correct |
41 |
Correct |
64 ms |
12608 KB |
Output is correct |
42 |
Correct |
65 ms |
13072 KB |
Output is correct |
43 |
Correct |
65 ms |
10388 KB |
Output is correct |
44 |
Correct |
78 ms |
15372 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2640 KB |
Output is correct |
2 |
Correct |
1 ms |
2640 KB |
Output is correct |
3 |
Correct |
1 ms |
2640 KB |
Output is correct |
4 |
Correct |
1 ms |
2640 KB |
Output is correct |
5 |
Correct |
1 ms |
2640 KB |
Output is correct |
6 |
Correct |
1 ms |
2640 KB |
Output is correct |
7 |
Correct |
2 ms |
2640 KB |
Output is correct |
8 |
Correct |
2 ms |
2640 KB |
Output is correct |
9 |
Correct |
1 ms |
2640 KB |
Output is correct |
10 |
Correct |
2 ms |
2640 KB |
Output is correct |
11 |
Correct |
1 ms |
2640 KB |
Output is correct |
12 |
Correct |
1 ms |
2640 KB |
Output is correct |
13 |
Correct |
2 ms |
2640 KB |
Output is correct |
14 |
Correct |
1 ms |
2640 KB |
Output is correct |
15 |
Correct |
2 ms |
2640 KB |
Output is correct |
16 |
Correct |
2 ms |
2640 KB |
Output is correct |
17 |
Correct |
2 ms |
2640 KB |
Output is correct |
18 |
Correct |
1 ms |
2640 KB |
Output is correct |
19 |
Correct |
1 ms |
2640 KB |
Output is correct |
20 |
Correct |
2 ms |
2800 KB |
Output is correct |
21 |
Correct |
2 ms |
2640 KB |
Output is correct |
22 |
Correct |
2 ms |
3004 KB |
Output is correct |
23 |
Correct |
2 ms |
2768 KB |
Output is correct |
24 |
Correct |
2 ms |
2896 KB |
Output is correct |
25 |
Correct |
4 ms |
2896 KB |
Output is correct |
26 |
Correct |
6 ms |
2768 KB |
Output is correct |
27 |
Correct |
4 ms |
2768 KB |
Output is correct |
28 |
Correct |
3 ms |
3060 KB |
Output is correct |
29 |
Correct |
3 ms |
3024 KB |
Output is correct |
30 |
Correct |
18 ms |
6596 KB |
Output is correct |
31 |
Correct |
8 ms |
4048 KB |
Output is correct |
32 |
Correct |
43 ms |
21832 KB |
Output is correct |
33 |
Correct |
22 ms |
8140 KB |
Output is correct |
34 |
Correct |
82 ms |
35156 KB |
Output is correct |
35 |
Correct |
71 ms |
11092 KB |
Output is correct |
36 |
Correct |
52 ms |
8256 KB |
Output is correct |
37 |
Correct |
55 ms |
8008 KB |
Output is correct |
38 |
Correct |
32 ms |
7764 KB |
Output is correct |
39 |
Correct |
39 ms |
7828 KB |
Output is correct |
40 |
Correct |
76 ms |
40892 KB |
Output is correct |
41 |
Correct |
64 ms |
12608 KB |
Output is correct |
42 |
Correct |
65 ms |
13072 KB |
Output is correct |
43 |
Correct |
65 ms |
10388 KB |
Output is correct |
44 |
Correct |
78 ms |
15372 KB |
Output is correct |
45 |
Runtime error |
5 ms |
5192 KB |
Execution killed with signal 11 |
46 |
Halted |
0 ms |
0 KB |
- |