Submission #1103897

# Submission time Handle Problem Language Result Execution time Memory
1103897 2024-10-22T07:15:44 Z epicci23 Game (APIO22_game) C++17
60 / 100
4000 ms 57500 KB
#include "bits/stdc++.h"
#include "game.h"
//#define int long long
#define all(v) v.begin() , v.end()
#define sz(a) (int)a.size()
using namespace std;

const int N = 3e5 + 5;
const int BL = 600;
vector<int> v[N],g[N];
bool vis[N],vis2[N];
int n,m,k,out[N],in[N],bin[N],bout[N];
bool ok=0;

void upd_in(int a,int val){
  if(in[a]<val || ok || bin[a]>bout[a]) return;
  in[a]=min(in[a],val);
  bin[a]=min(bin[a],val/BL);
  if(in[a]<out[a] || bin[a]<bout[a]){
    ok=1;
    return;
  }
  if(in[a]==out[a] && a>=k){
  	ok=1;
    return;
  }
  for(int x:g[a]){
  	if(bin[x]!=bin[a]) continue;
  	if(val<in[x]) upd_in(x,val);
  }
}

void upd_out(int a,int val){
  if(out[a]>val || ok || bin[a]>bout[a]) return;
  out[a]=max(out[a],val);
  bout[a]=max(bout[a],val/BL);
  if(in[a]<out[a] || bin[a]<bout[a]){
    ok=1;
    return;
  }
  if(in[a]==out[a] && a>=k){
  	ok=1;
    return;
  }
  for(int x:v[a]){
  	if(bin[x]!=bin[a]) continue;
  	if(out[x]<val) upd_out(x,val);
  }
}

void upd_bin(int a,int val,int real){
  if(bin[a]<=val || ok) return;
  bin[a]=val;
  
  if(bin[a]<bout[a] || in[a]<out[a]){
    ok=1;
    return;
  }
  if(in[a]==out[a] && a>=k){
  	ok=1;
    return;
  }
  if(bin[a]==bout[a] && !vis[a]){
  	vis[a]=vis2[a]=1;
    for(int u=BL*bin[a];u<min(k,BL*(bin[a]+1));u++) 
      upd_out(u,out[u]);
    for(int u=BL*bin[a];u<min(k,BL*(bin[a]+1));u++) 
      upd_in(u,in[u]);
  }
  else upd_in(a,in[a]);
  
  for(int x:g[a]){
  	if(bin[x]>val) upd_bin(x,val,in[a]);
  	else if(bin[x]==val) upd_in(x,in[a]);
  }
}

void upd_bout(int a,int val,int real){
  if(bout[a]>=val || ok) return;
  bout[a]=val;
  if(bin[a]<bout[a] || in[a]<out[a]){
    ok=1;
    return;
  }
  if(in[a]==out[a] && a>=k){
  	ok=1;
    return;
  }
  if(bin[a]==bout[a] && !vis2[a]){
  	vis[a]=vis2[a]=1;
    for(int u=BL*bout[a];u<min(k,BL*(bout[a]+1));u++) 
      upd_out(u,out[u]);
    for(int u=BL*bout[a];u<min(k,BL*(bout[a]+1));u++) 
      upd_in(u,in[u]);
  }
  else upd_out(a,out[a]);
  for(int x:v[a]){
  	if(bout[x]<val) upd_bout(x,val,out[a]);
  	else if(bout[x]==val) upd_out(x,out[a]);
  }
}

void init(int _n,int _k){
  n=_n,k=_k;
  for(int i=1;i<k;i++){
  	v[i-1].push_back(i);
  	g[i].push_back(i-1);
  }
  fill(bout,bout+N,-1);
  fill(bin,bin+N,k);
  fill(out,out+N,-1);
  fill(in,in+N,k);
  for(int i=0;i<k;i++) bin[i]=bout[i]=i/BL;
  for(int i=0;i<k;i++) in[i]=out[i]=i;
}

int add_teleporter(int a, int b){
  if(a==b && a<k) ok=1;
  if(a<k && b<k && a>b) ok=1;
  v[a].push_back(b);
  g[b].push_back(a);
  upd_bout(b,bout[a],out[a]);
  upd_bin(a,bin[b],in[b]);
  upd_in(a,in[b]);
  upd_out(b,out[a]);
  return ok;
}

/*void _(){
  cin >> n >> m >> k;
  init(n,k);
  for(int i=1;i<=m;i++){
  	int a,b;
  	cin >> a >> b;
  	cout << add_teleporter(a,b) << '\n';
  }
}

int32_t main(){
  cin.tie(0); ios::sync_with_stdio(0);
  int tc=1;//cin >> tc;
  while(tc--) _();
  return 0;
}*/

# Verdict Execution time Memory Grader output
1 Correct 4 ms 19792 KB Output is correct
2 Correct 5 ms 19600 KB Output is correct
3 Correct 5 ms 19792 KB Output is correct
4 Correct 5 ms 20040 KB Output is correct
5 Correct 5 ms 19792 KB Output is correct
6 Correct 5 ms 19644 KB Output is correct
7 Correct 5 ms 19792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 19792 KB Output is correct
2 Correct 5 ms 19600 KB Output is correct
3 Correct 5 ms 19792 KB Output is correct
4 Correct 5 ms 20040 KB Output is correct
5 Correct 5 ms 19792 KB Output is correct
6 Correct 5 ms 19644 KB Output is correct
7 Correct 5 ms 19792 KB Output is correct
8 Correct 4 ms 19792 KB Output is correct
9 Correct 4 ms 19792 KB Output is correct
10 Correct 4 ms 19792 KB Output is correct
11 Correct 4 ms 19792 KB Output is correct
12 Correct 4 ms 19808 KB Output is correct
13 Correct 4 ms 19792 KB Output is correct
14 Correct 4 ms 19792 KB Output is correct
15 Correct 4 ms 19792 KB Output is correct
16 Correct 4 ms 19792 KB Output is correct
17 Correct 4 ms 19792 KB Output is correct
18 Correct 4 ms 19792 KB Output is correct
19 Correct 4 ms 19684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 19792 KB Output is correct
2 Correct 5 ms 19600 KB Output is correct
3 Correct 5 ms 19792 KB Output is correct
4 Correct 5 ms 20040 KB Output is correct
5 Correct 5 ms 19792 KB Output is correct
6 Correct 5 ms 19644 KB Output is correct
7 Correct 5 ms 19792 KB Output is correct
8 Correct 4 ms 19792 KB Output is correct
9 Correct 4 ms 19792 KB Output is correct
10 Correct 4 ms 19792 KB Output is correct
11 Correct 4 ms 19792 KB Output is correct
12 Correct 4 ms 19808 KB Output is correct
13 Correct 4 ms 19792 KB Output is correct
14 Correct 4 ms 19792 KB Output is correct
15 Correct 4 ms 19792 KB Output is correct
16 Correct 4 ms 19792 KB Output is correct
17 Correct 4 ms 19792 KB Output is correct
18 Correct 4 ms 19792 KB Output is correct
19 Correct 4 ms 19684 KB Output is correct
20 Correct 4 ms 19792 KB Output is correct
21 Correct 6 ms 19792 KB Output is correct
22 Correct 6 ms 19792 KB Output is correct
23 Correct 4 ms 19792 KB Output is correct
24 Correct 10 ms 19792 KB Output is correct
25 Correct 8 ms 19792 KB Output is correct
26 Correct 7 ms 19792 KB Output is correct
27 Correct 10 ms 19792 KB Output is correct
28 Correct 8 ms 19792 KB Output is correct
29 Correct 9 ms 19880 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 19792 KB Output is correct
2 Correct 5 ms 19600 KB Output is correct
3 Correct 5 ms 19792 KB Output is correct
4 Correct 5 ms 20040 KB Output is correct
5 Correct 5 ms 19792 KB Output is correct
6 Correct 5 ms 19644 KB Output is correct
7 Correct 5 ms 19792 KB Output is correct
8 Correct 4 ms 19792 KB Output is correct
9 Correct 4 ms 19792 KB Output is correct
10 Correct 4 ms 19792 KB Output is correct
11 Correct 4 ms 19792 KB Output is correct
12 Correct 4 ms 19808 KB Output is correct
13 Correct 4 ms 19792 KB Output is correct
14 Correct 4 ms 19792 KB Output is correct
15 Correct 4 ms 19792 KB Output is correct
16 Correct 4 ms 19792 KB Output is correct
17 Correct 4 ms 19792 KB Output is correct
18 Correct 4 ms 19792 KB Output is correct
19 Correct 4 ms 19684 KB Output is correct
20 Correct 4 ms 19792 KB Output is correct
21 Correct 6 ms 19792 KB Output is correct
22 Correct 6 ms 19792 KB Output is correct
23 Correct 4 ms 19792 KB Output is correct
24 Correct 10 ms 19792 KB Output is correct
25 Correct 8 ms 19792 KB Output is correct
26 Correct 7 ms 19792 KB Output is correct
27 Correct 10 ms 19792 KB Output is correct
28 Correct 8 ms 19792 KB Output is correct
29 Correct 9 ms 19880 KB Output is correct
30 Correct 14 ms 20816 KB Output is correct
31 Correct 7 ms 20048 KB Output is correct
32 Correct 44 ms 23284 KB Output is correct
33 Correct 18 ms 21696 KB Output is correct
34 Correct 918 ms 25088 KB Output is correct
35 Correct 621 ms 22856 KB Output is correct
36 Correct 75 ms 21832 KB Output is correct
37 Correct 261 ms 21840 KB Output is correct
38 Correct 485 ms 21320 KB Output is correct
39 Correct 631 ms 21364 KB Output is correct
40 Correct 1553 ms 25056 KB Output is correct
41 Correct 507 ms 22228 KB Output is correct
42 Correct 191 ms 22088 KB Output is correct
43 Correct 244 ms 22600 KB Output is correct
44 Correct 440 ms 23376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 19792 KB Output is correct
2 Correct 5 ms 19600 KB Output is correct
3 Correct 5 ms 19792 KB Output is correct
4 Correct 5 ms 20040 KB Output is correct
5 Correct 5 ms 19792 KB Output is correct
6 Correct 5 ms 19644 KB Output is correct
7 Correct 5 ms 19792 KB Output is correct
8 Correct 4 ms 19792 KB Output is correct
9 Correct 4 ms 19792 KB Output is correct
10 Correct 4 ms 19792 KB Output is correct
11 Correct 4 ms 19792 KB Output is correct
12 Correct 4 ms 19808 KB Output is correct
13 Correct 4 ms 19792 KB Output is correct
14 Correct 4 ms 19792 KB Output is correct
15 Correct 4 ms 19792 KB Output is correct
16 Correct 4 ms 19792 KB Output is correct
17 Correct 4 ms 19792 KB Output is correct
18 Correct 4 ms 19792 KB Output is correct
19 Correct 4 ms 19684 KB Output is correct
20 Correct 4 ms 19792 KB Output is correct
21 Correct 6 ms 19792 KB Output is correct
22 Correct 6 ms 19792 KB Output is correct
23 Correct 4 ms 19792 KB Output is correct
24 Correct 10 ms 19792 KB Output is correct
25 Correct 8 ms 19792 KB Output is correct
26 Correct 7 ms 19792 KB Output is correct
27 Correct 10 ms 19792 KB Output is correct
28 Correct 8 ms 19792 KB Output is correct
29 Correct 9 ms 19880 KB Output is correct
30 Correct 14 ms 20816 KB Output is correct
31 Correct 7 ms 20048 KB Output is correct
32 Correct 44 ms 23284 KB Output is correct
33 Correct 18 ms 21696 KB Output is correct
34 Correct 918 ms 25088 KB Output is correct
35 Correct 621 ms 22856 KB Output is correct
36 Correct 75 ms 21832 KB Output is correct
37 Correct 261 ms 21840 KB Output is correct
38 Correct 485 ms 21320 KB Output is correct
39 Correct 631 ms 21364 KB Output is correct
40 Correct 1553 ms 25056 KB Output is correct
41 Correct 507 ms 22228 KB Output is correct
42 Correct 191 ms 22088 KB Output is correct
43 Correct 244 ms 22600 KB Output is correct
44 Correct 440 ms 23376 KB Output is correct
45 Correct 168 ms 31328 KB Output is correct
46 Correct 7 ms 20304 KB Output is correct
47 Correct 7 ms 20304 KB Output is correct
48 Correct 473 ms 57500 KB Output is correct
49 Correct 210 ms 38508 KB Output is correct
50 Execution timed out 4061 ms 48512 KB Time limit exceeded
51 Halted 0 ms 0 KB -