답안 #1103814

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1103814 2024-10-21T20:35:06 Z epicci23 게임 (APIO22_game) C++17
2 / 100
15 ms 19164 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];
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) return;
  //cout << "updin: " << a << ' ' << val << '\n';
  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(in[x]>val && bin[x]==bin[a]) upd_in(x,val);
}

void upd_out(int a,int val){
  if(out[a]>val || ok) return;
  //cout << "updout: " << a << ' ' << val << '\n';
  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(out[x]<val && bout[x]==bout[a]) upd_out(x,val);
}

void upd_bin(int a,int val,int real){
  if(bin[a]<=val || ok) return;
  bin[a]=val;
  //cout << "updbin: " << a << ' ' << val << '\n';
  in[a]=min(in[a],real);
  if(bin[a]<bout[a]){
    ok=1;
    return;
  }
  if(bin[a]==bout[a] && a>=k){
  	upd_in(a,in[a]);
  	upd_in(in[a],in[a]);
  }
  for(int x:g[a]) if(bin[x]>val) upd_bin(x,val,in[a]);
}

void upd_bout(int a,int val,int real){
  if(bout[a]>=val || ok) return;
  bout[a]=val;
  //cout << "updbout: " << a << ' ' << val << '\n';
  out[a]=max(out[a],real);
  if(bin[a]<bout[a]){
    ok=1;
    return;
  }
  if(bin[a]==bout[a] && a>=k){
  	upd_out(a,out[a]);
  	upd_out(out[a],out[a]);
  }
  for(int x:v[a]) if(bout[x]<val) upd_bout(x,val,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]);
  return ok;
}

/*void _(){
  cin >> n >> m >> 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;
  for(int i=1;i<=m;i++){
  	int a,b;
  	cin >> a >> 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]);
  	cout << ok << '\n';
  }
}

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

# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 19024 KB Output is correct
2 Correct 12 ms 19164 KB Output is correct
3 Correct 12 ms 19024 KB Output is correct
4 Correct 14 ms 19032 KB Output is correct
5 Correct 15 ms 19024 KB Output is correct
6 Correct 14 ms 19144 KB Output is correct
7 Correct 14 ms 19024 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 19024 KB Output is correct
2 Correct 12 ms 19164 KB Output is correct
3 Correct 12 ms 19024 KB Output is correct
4 Correct 14 ms 19032 KB Output is correct
5 Correct 15 ms 19024 KB Output is correct
6 Correct 14 ms 19144 KB Output is correct
7 Correct 14 ms 19024 KB Output is correct
8 Correct 15 ms 19024 KB Output is correct
9 Correct 14 ms 19024 KB Output is correct
10 Correct 14 ms 19024 KB Output is correct
11 Correct 15 ms 19024 KB Output is correct
12 Correct 15 ms 19024 KB Output is correct
13 Incorrect 14 ms 19024 KB Wrong Answer[1]
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 19024 KB Output is correct
2 Correct 12 ms 19164 KB Output is correct
3 Correct 12 ms 19024 KB Output is correct
4 Correct 14 ms 19032 KB Output is correct
5 Correct 15 ms 19024 KB Output is correct
6 Correct 14 ms 19144 KB Output is correct
7 Correct 14 ms 19024 KB Output is correct
8 Correct 15 ms 19024 KB Output is correct
9 Correct 14 ms 19024 KB Output is correct
10 Correct 14 ms 19024 KB Output is correct
11 Correct 15 ms 19024 KB Output is correct
12 Correct 15 ms 19024 KB Output is correct
13 Incorrect 14 ms 19024 KB Wrong Answer[1]
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 19024 KB Output is correct
2 Correct 12 ms 19164 KB Output is correct
3 Correct 12 ms 19024 KB Output is correct
4 Correct 14 ms 19032 KB Output is correct
5 Correct 15 ms 19024 KB Output is correct
6 Correct 14 ms 19144 KB Output is correct
7 Correct 14 ms 19024 KB Output is correct
8 Correct 15 ms 19024 KB Output is correct
9 Correct 14 ms 19024 KB Output is correct
10 Correct 14 ms 19024 KB Output is correct
11 Correct 15 ms 19024 KB Output is correct
12 Correct 15 ms 19024 KB Output is correct
13 Incorrect 14 ms 19024 KB Wrong Answer[1]
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 19024 KB Output is correct
2 Correct 12 ms 19164 KB Output is correct
3 Correct 12 ms 19024 KB Output is correct
4 Correct 14 ms 19032 KB Output is correct
5 Correct 15 ms 19024 KB Output is correct
6 Correct 14 ms 19144 KB Output is correct
7 Correct 14 ms 19024 KB Output is correct
8 Correct 15 ms 19024 KB Output is correct
9 Correct 14 ms 19024 KB Output is correct
10 Correct 14 ms 19024 KB Output is correct
11 Correct 15 ms 19024 KB Output is correct
12 Correct 15 ms 19024 KB Output is correct
13 Incorrect 14 ms 19024 KB Wrong Answer[1]
14 Halted 0 ms 0 KB -