# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
974996 |
2024-05-04T09:19:14 Z |
AlperenT_ |
Game (APIO22_game) |
C++17 |
|
4000 ms |
63008 KB |
#include "game.h"
#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#define pb push_back
#define F first
#define S second
#define ld long double
#define all(a) a.begin(),a.end()
#define pii pair <int,int>
#define ll long long
#define sz(v) (int)v.size()
#define rep(i , a , b) for(int i=a;i <= (b);i++)
#define per(i , a , b) for(int i=a;i >= (b);i--)
#define deb(x) cout <<#x << " : " << x << "\n" ;
using namespace std ;
const int maxn = 3e5 + 10 , maxq = 32, inf = 1e9+10 , lg = 19 ,sq = 707 ,mod = 998244353 ;
bitset <maxn/sq+100> v1[maxn] , v2[maxn] ;
int l[maxn] , r[maxn] , n , k;
vector <int> G[maxn] , Gr[maxn];
void dl(int v, int x){
if(l[v]<= x)return ;
l[v] = x ;
for(int u : Gr[v]){
dl(u,x);
}
}
void dr(int v ,int x){
if(r[v] >= x )return ;;
r[v]= x;
for(int u : G[v]){
dr(u,x);
}
}
void d1(int v , int i){
if(v1[v][i] == 1)return ;
v1[v][i] = 1;
for(int u : Gr[v]){
d1(u , i) ;
}
}
void d2(int v ,int i){
if(v2[v][i] == 1)return ;
v2[v][i] = 1;
for(int u : G[v]){
d2(u , i) ;
}
}
void init(int N, int K) {
n = N ; k = K ;
rep(i , 0 , n-1){
l[i] = inf ;
r[i] =-1 ;
}
rep(i , 0 , k-1){
for(int j = 0 ; j*sq < k ; j++){
if(j*sq <= i){
v2[i][j] = 1;
}
if(j*sq >= i){
v1[i][j] = 1 ;
}
}
}
rep(i , 0 , k-1){
l[i] = r[i] =i;
}
}
int add_teleporter(int v, int u) {
if(l[u]<=r[v]){
return 1 ;
}
for(int i = 0 ; i*sq < k ; i++){
// if(v1[u][i]==1 && v2[v][i]==1)return 1 ;
}
G[v].pb(u);
Gr[u].pb(v);
if(l[u]!=inf)dl(v , l[u]) ;
if(r[v]!=-1)dr(u ,r[v]);
for(int i = 0 ; i*sq < k ; i++){
if(v1[u][i] == 1){
d1(v,i);
}
if(v2[v][i] == 1){
d2(u , i) ;
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
19032 KB |
Output is correct |
2 |
Correct |
4 ms |
19032 KB |
Output is correct |
3 |
Correct |
4 ms |
19192 KB |
Output is correct |
4 |
Correct |
5 ms |
19032 KB |
Output is correct |
5 |
Correct |
5 ms |
19032 KB |
Output is correct |
6 |
Correct |
4 ms |
19032 KB |
Output is correct |
7 |
Correct |
4 ms |
19032 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
19032 KB |
Output is correct |
2 |
Correct |
4 ms |
19032 KB |
Output is correct |
3 |
Correct |
4 ms |
19192 KB |
Output is correct |
4 |
Correct |
5 ms |
19032 KB |
Output is correct |
5 |
Correct |
5 ms |
19032 KB |
Output is correct |
6 |
Correct |
4 ms |
19032 KB |
Output is correct |
7 |
Correct |
4 ms |
19032 KB |
Output is correct |
8 |
Correct |
4 ms |
19032 KB |
Output is correct |
9 |
Correct |
4 ms |
19032 KB |
Output is correct |
10 |
Correct |
4 ms |
19032 KB |
Output is correct |
11 |
Correct |
4 ms |
19032 KB |
Output is correct |
12 |
Correct |
5 ms |
19284 KB |
Output is correct |
13 |
Correct |
4 ms |
19032 KB |
Output is correct |
14 |
Correct |
5 ms |
19032 KB |
Output is correct |
15 |
Correct |
5 ms |
19032 KB |
Output is correct |
16 |
Correct |
4 ms |
19032 KB |
Output is correct |
17 |
Correct |
4 ms |
19032 KB |
Output is correct |
18 |
Correct |
4 ms |
19032 KB |
Output is correct |
19 |
Correct |
4 ms |
18856 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
19032 KB |
Output is correct |
2 |
Correct |
4 ms |
19032 KB |
Output is correct |
3 |
Correct |
4 ms |
19192 KB |
Output is correct |
4 |
Correct |
5 ms |
19032 KB |
Output is correct |
5 |
Correct |
5 ms |
19032 KB |
Output is correct |
6 |
Correct |
4 ms |
19032 KB |
Output is correct |
7 |
Correct |
4 ms |
19032 KB |
Output is correct |
8 |
Correct |
4 ms |
19032 KB |
Output is correct |
9 |
Correct |
4 ms |
19032 KB |
Output is correct |
10 |
Correct |
4 ms |
19032 KB |
Output is correct |
11 |
Correct |
4 ms |
19032 KB |
Output is correct |
12 |
Correct |
5 ms |
19284 KB |
Output is correct |
13 |
Correct |
4 ms |
19032 KB |
Output is correct |
14 |
Correct |
5 ms |
19032 KB |
Output is correct |
15 |
Correct |
5 ms |
19032 KB |
Output is correct |
16 |
Correct |
4 ms |
19032 KB |
Output is correct |
17 |
Correct |
4 ms |
19032 KB |
Output is correct |
18 |
Correct |
4 ms |
19032 KB |
Output is correct |
19 |
Correct |
4 ms |
18856 KB |
Output is correct |
20 |
Correct |
4 ms |
19032 KB |
Output is correct |
21 |
Correct |
4 ms |
19032 KB |
Output is correct |
22 |
Correct |
4 ms |
19288 KB |
Output is correct |
23 |
Correct |
5 ms |
19100 KB |
Output is correct |
24 |
Correct |
6 ms |
19032 KB |
Output is correct |
25 |
Correct |
6 ms |
19064 KB |
Output is correct |
26 |
Correct |
6 ms |
19544 KB |
Output is correct |
27 |
Correct |
6 ms |
19288 KB |
Output is correct |
28 |
Correct |
4 ms |
19032 KB |
Output is correct |
29 |
Correct |
5 ms |
19028 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
19032 KB |
Output is correct |
2 |
Correct |
4 ms |
19032 KB |
Output is correct |
3 |
Correct |
4 ms |
19192 KB |
Output is correct |
4 |
Correct |
5 ms |
19032 KB |
Output is correct |
5 |
Correct |
5 ms |
19032 KB |
Output is correct |
6 |
Correct |
4 ms |
19032 KB |
Output is correct |
7 |
Correct |
4 ms |
19032 KB |
Output is correct |
8 |
Correct |
4 ms |
19032 KB |
Output is correct |
9 |
Correct |
4 ms |
19032 KB |
Output is correct |
10 |
Correct |
4 ms |
19032 KB |
Output is correct |
11 |
Correct |
4 ms |
19032 KB |
Output is correct |
12 |
Correct |
5 ms |
19284 KB |
Output is correct |
13 |
Correct |
4 ms |
19032 KB |
Output is correct |
14 |
Correct |
5 ms |
19032 KB |
Output is correct |
15 |
Correct |
5 ms |
19032 KB |
Output is correct |
16 |
Correct |
4 ms |
19032 KB |
Output is correct |
17 |
Correct |
4 ms |
19032 KB |
Output is correct |
18 |
Correct |
4 ms |
19032 KB |
Output is correct |
19 |
Correct |
4 ms |
18856 KB |
Output is correct |
20 |
Correct |
4 ms |
19032 KB |
Output is correct |
21 |
Correct |
4 ms |
19032 KB |
Output is correct |
22 |
Correct |
4 ms |
19288 KB |
Output is correct |
23 |
Correct |
5 ms |
19100 KB |
Output is correct |
24 |
Correct |
6 ms |
19032 KB |
Output is correct |
25 |
Correct |
6 ms |
19064 KB |
Output is correct |
26 |
Correct |
6 ms |
19544 KB |
Output is correct |
27 |
Correct |
6 ms |
19288 KB |
Output is correct |
28 |
Correct |
4 ms |
19032 KB |
Output is correct |
29 |
Correct |
5 ms |
19028 KB |
Output is correct |
30 |
Correct |
24 ms |
22140 KB |
Output is correct |
31 |
Correct |
8 ms |
20312 KB |
Output is correct |
32 |
Correct |
24 ms |
23912 KB |
Output is correct |
33 |
Correct |
23 ms |
23384 KB |
Output is correct |
34 |
Correct |
878 ms |
23908 KB |
Output is correct |
35 |
Correct |
313 ms |
23944 KB |
Output is correct |
36 |
Correct |
34 ms |
23500 KB |
Output is correct |
37 |
Correct |
35 ms |
23144 KB |
Output is correct |
38 |
Correct |
33 ms |
22992 KB |
Output is correct |
39 |
Correct |
37 ms |
23080 KB |
Output is correct |
40 |
Correct |
734 ms |
24856 KB |
Output is correct |
41 |
Correct |
156 ms |
23600 KB |
Output is correct |
42 |
Correct |
90 ms |
23352 KB |
Output is correct |
43 |
Correct |
45 ms |
24224 KB |
Output is correct |
44 |
Correct |
608 ms |
24044 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
19032 KB |
Output is correct |
2 |
Correct |
4 ms |
19032 KB |
Output is correct |
3 |
Correct |
4 ms |
19192 KB |
Output is correct |
4 |
Correct |
5 ms |
19032 KB |
Output is correct |
5 |
Correct |
5 ms |
19032 KB |
Output is correct |
6 |
Correct |
4 ms |
19032 KB |
Output is correct |
7 |
Correct |
4 ms |
19032 KB |
Output is correct |
8 |
Correct |
4 ms |
19032 KB |
Output is correct |
9 |
Correct |
4 ms |
19032 KB |
Output is correct |
10 |
Correct |
4 ms |
19032 KB |
Output is correct |
11 |
Correct |
4 ms |
19032 KB |
Output is correct |
12 |
Correct |
5 ms |
19284 KB |
Output is correct |
13 |
Correct |
4 ms |
19032 KB |
Output is correct |
14 |
Correct |
5 ms |
19032 KB |
Output is correct |
15 |
Correct |
5 ms |
19032 KB |
Output is correct |
16 |
Correct |
4 ms |
19032 KB |
Output is correct |
17 |
Correct |
4 ms |
19032 KB |
Output is correct |
18 |
Correct |
4 ms |
19032 KB |
Output is correct |
19 |
Correct |
4 ms |
18856 KB |
Output is correct |
20 |
Correct |
4 ms |
19032 KB |
Output is correct |
21 |
Correct |
4 ms |
19032 KB |
Output is correct |
22 |
Correct |
4 ms |
19288 KB |
Output is correct |
23 |
Correct |
5 ms |
19100 KB |
Output is correct |
24 |
Correct |
6 ms |
19032 KB |
Output is correct |
25 |
Correct |
6 ms |
19064 KB |
Output is correct |
26 |
Correct |
6 ms |
19544 KB |
Output is correct |
27 |
Correct |
6 ms |
19288 KB |
Output is correct |
28 |
Correct |
4 ms |
19032 KB |
Output is correct |
29 |
Correct |
5 ms |
19028 KB |
Output is correct |
30 |
Correct |
24 ms |
22140 KB |
Output is correct |
31 |
Correct |
8 ms |
20312 KB |
Output is correct |
32 |
Correct |
24 ms |
23912 KB |
Output is correct |
33 |
Correct |
23 ms |
23384 KB |
Output is correct |
34 |
Correct |
878 ms |
23908 KB |
Output is correct |
35 |
Correct |
313 ms |
23944 KB |
Output is correct |
36 |
Correct |
34 ms |
23500 KB |
Output is correct |
37 |
Correct |
35 ms |
23144 KB |
Output is correct |
38 |
Correct |
33 ms |
22992 KB |
Output is correct |
39 |
Correct |
37 ms |
23080 KB |
Output is correct |
40 |
Correct |
734 ms |
24856 KB |
Output is correct |
41 |
Correct |
156 ms |
23600 KB |
Output is correct |
42 |
Correct |
90 ms |
23352 KB |
Output is correct |
43 |
Correct |
45 ms |
24224 KB |
Output is correct |
44 |
Correct |
608 ms |
24044 KB |
Output is correct |
45 |
Correct |
193 ms |
35108 KB |
Output is correct |
46 |
Correct |
8 ms |
19544 KB |
Output is correct |
47 |
Correct |
9 ms |
20056 KB |
Output is correct |
48 |
Correct |
330 ms |
61796 KB |
Output is correct |
49 |
Correct |
256 ms |
57492 KB |
Output is correct |
50 |
Execution timed out |
4086 ms |
63008 KB |
Time limit exceeded |
51 |
Halted |
0 ms |
0 KB |
- |