#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 , 0){
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){
ans[k][j] = bit(j-1, i-1) + c + 3 ;
}
}
}
c+=3 ;
}
vector <vector<int> > vec ;
rep(i , 0 , c-1){
vector <int> a ;
rep(j , 0 , n)a.pb(ans[i][j]) ;
vec.pb(a);
}
return vec;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |