This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "prison.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define INF 1e18
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define OK cout<<"Ok"<<endl;
#define MOD (ll)(1e9+7)
const int mxn=5e3+5;
int color[mxn];
int digit(int k,int idx){
if(idx>7){
return 0;
}
if(idx<0) idx=0;
vector<int>vt;
while(k>0){
vt.pb(k%3);
k/=3;
}
while(vt.size()<8){
vt.pb(0);
}
return vt[7-idx];
}
int lst(int idx){
if(idx==0) return 0;
if(idx<=6) return 6;
if(idx<=12) return 12;
if(idx<=18) return 18;
return 0;
}
int lst2(int idx){
if(idx<=3) return 3;
if(idx<=9) return 9;
if(idx<=15) return 15;
if(idx<=21) return 21;
return 0;
}
vector<vector<int>> devise_strategy(int n) {
color[0]=1;
int k=0,qq=-1;
for(int i=1;i<=24;i++){
k++;
if(k>3){
k=1;
qq=qq*-1;
}
color[i]=k*qq;
}
vector<vector<int>>ans;
for(int id=0;id<23;id++){
if(color[id]>0){
vector<int>vt;
vt.pb(0);
for(int i=1;i<=n;i++){
int idx=(id+2)/3-1;
int q=digit(i,idx);
if(id==0){
vt.pb(id+q+1);
}
else if(id==22){
if(digit(i,idx)==0){
vt.pb(-1);
}
else{
vt.pb(-2);
}
}
else{
if(color[id]-1<q){
vt.pb(-2);
}
else if(color[id]-1>q){
vt.pb(-1);
}
else{
int q=digit(i,idx+1);
vt.pb(lst(id)+q+1);
}
}
}
ans.pb(vt);
}
else{
vector<int>vt;
vt.pb(1);
for(int i=1;i<=n;i++){
int idx=(id+2)/3-1;
int q=digit(i,idx);
if(-color[id]-1<q){
vt.pb(-1);
}
else if(-color[id]-1>q){
vt.pb(-2);
}
else{
if(id>=19){
int q=digit(i,idx+1);
if(q==0){
vt.pb(-2);
}
else if(q==2){
vt.pb(-1);
}
else{
vt.pb(22);
}
}
else{
int q=digit(i,idx+1);
vt.pb(lst2(id)+q+1);
}
}
}
ans.pb(vt);
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |