제출 #1239031

#제출 시각아이디문제언어결과실행 시간메모리
1239031AlperenT_죄수들의 도전 (IOI22_prison)C++20
80 / 100
7 ms1608 KiB
#include "prison.h"
#include <bits/stdc++.h> 
#define pb push_back
#define F first
#define pii pair<int,int> 
#define all(a) a.begin(),a.end()
#define S second 
#define sz(a) (int)a.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 ld double
#define ll long long 
using namespace std ;
const int maxn = 2e5 + 10 , inf = 1e9+ 10 , mod = 998244353;
int n ;
int ans[30][maxn];

int bit(int x , int w){
    while(w>0){
        x/=3 ;
        w--;
    }
    return x%3 ;
}
int win(int x){
    if(x==0){
        return -1; 
    }
    return -2 ;
}

std::vector<std::vector<int>> devise_strategy(int N) {
    n = N ;
    bool f = 0 ;int c = 1 ; 
    ans[0][0] = f ;
    rep(i ,1, n){
        ans[0][i] = bit(i-1 , 7) + c;
    }
    per(i , 7 , 1){
        f ^= 1 ;
        rep(k ,c , c+2){
            ans[k][0] = f; 
            rep(j , 1 , n){
                if(bit(j-1 , i) < k-c){
                    ans[k][j] = win(f) ;
                    continue ;
                }
                if(bit(j-1 , i) > k-c){
                    ans[k][j] = win(f^1); 
                    continue ; 
                }
                if(i == 0){
                    ans[k][j] = 0 ;
                    continue ;
                }
                if(bit(j-1 , i) == k-c){
                    if(i==1){
                        if(bit(j-1,i-1)==0){
                            ans[k][j] = win(f) ;
                        }
                        if(bit(j-1, i-1) == 2){
                            ans[k][j] = win(f^1) ;
                        }
                        if(bit(j-1 , i-1) == 1){
                            ans[k][j] = c+3 ;
                        }
                        continue ;
                    }
                    ans[k][j] = bit(j-1, i-1) + c + 3 ; 
                }
            }
        }
        c+=3 ;
    }
    ans[c][0] = f^1 ;
    f^=1;
    rep(j ,1 ,n){
        if(bit(j-1 , 0) == 0){
            ans[c][j] = win(f) ;
        }
        if(bit(j-1 , 0) == 2){
            ans[c][j] = win(f^1) ;
        }
    }
    vector <vector<int> > vec ;
    rep(i , 0 , c){
        vector <int> a ;
        rep(j , 0 , n)a.pb(ans[i][j]) ;
        vec.pb(a);
    }
    return vec;
    
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...