답안 #974980

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
974980 2024-05-04T08:53:43 Z AlperenT_ 게임 (APIO22_game) C++17
2 / 100
5 ms 19288 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 || l[v]/sq!=r[v]/sq)return ;
  l[v] = x ;
  for(int u : Gr[v]){
    dl(u,x);
  }
}
void dr(int v ,int x){
  if(r[v] >= x  || l[v]/sq != r[v]/sq)return ;;
  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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 19032 KB Output is correct
2 Correct 4 ms 19032 KB Output is correct
3 Correct 4 ms 19032 KB Output is correct
4 Correct 4 ms 19032 KB Output is correct
5 Correct 4 ms 19032 KB Output is correct
6 Correct 4 ms 19288 KB Output is correct
7 Correct 5 ms 19288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 19032 KB Output is correct
2 Correct 4 ms 19032 KB Output is correct
3 Correct 4 ms 19032 KB Output is correct
4 Correct 4 ms 19032 KB Output is correct
5 Correct 4 ms 19032 KB Output is correct
6 Correct 4 ms 19288 KB Output is correct
7 Correct 5 ms 19288 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 Incorrect 4 ms 19032 KB Wrong Answer[1]
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 19032 KB Output is correct
2 Correct 4 ms 19032 KB Output is correct
3 Correct 4 ms 19032 KB Output is correct
4 Correct 4 ms 19032 KB Output is correct
5 Correct 4 ms 19032 KB Output is correct
6 Correct 4 ms 19288 KB Output is correct
7 Correct 5 ms 19288 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 Incorrect 4 ms 19032 KB Wrong Answer[1]
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 19032 KB Output is correct
2 Correct 4 ms 19032 KB Output is correct
3 Correct 4 ms 19032 KB Output is correct
4 Correct 4 ms 19032 KB Output is correct
5 Correct 4 ms 19032 KB Output is correct
6 Correct 4 ms 19288 KB Output is correct
7 Correct 5 ms 19288 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 Incorrect 4 ms 19032 KB Wrong Answer[1]
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 19032 KB Output is correct
2 Correct 4 ms 19032 KB Output is correct
3 Correct 4 ms 19032 KB Output is correct
4 Correct 4 ms 19032 KB Output is correct
5 Correct 4 ms 19032 KB Output is correct
6 Correct 4 ms 19288 KB Output is correct
7 Correct 5 ms 19288 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 Incorrect 4 ms 19032 KB Wrong Answer[1]
12 Halted 0 ms 0 KB -