Submission #974984

# Submission time Handle Problem Language Result Execution time Memory
974984 2024-05-04T08:59:08 Z AlperenT_ Game (APIO22_game) C++17
Compilation error
0 ms 0 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];
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] =0 ;
  }
  rep(i , 0 , k-1){
    l[i] = r[i] =i;
  }
}

int add_teleporter(int u, int v) {
  if(min(l[u],l[v])<= max(r[v],r[u])){
    return 1 ;
  }
  for(int i = 0 ; i*sq <= n ; i++){
    if(v1[u][i]==1 && v2[v][i]==1)return 1 ;
  }
  G[v].pb(u);
  Gr[u].pb(v); 
  if(l[v]/sq != r[v]/sq && l[u]/sq != r[v]/sq){
    dl(v , l[u]) ;
    dr(u ,r[v]);
  }
  for(int i = 0 ; i*sq <= n ; i++){
    if(v1[u][i] == 1){
      d1(v,i);
    }
    if(v2[v][i] == 1){
      d2(u , i) ;
    }
  }
  return 0;
}

Compilation message

game.cpp: In function 'void init(int, int)':
game.cpp:55:3: error: 'n' was not declared in this scope
   55 |   n = N ; K = k ;
      |   ^
game.cpp:55:15: error: 'k' was not declared in this scope
   55 |   n = N ; K = k ;
      |               ^
game.cpp: In function 'int add_teleporter(int, int)':
game.cpp:69:27: error: 'n' was not declared in this scope
   69 |   for(int i = 0 ; i*sq <= n ; i++){
      |                           ^
game.cpp:78:27: error: 'n' was not declared in this scope
   78 |   for(int i = 0 ; i*sq <= n ; i++){
      |                           ^