Submission #1120070

#TimeUsernameProblemLanguageResultExecution timeMemory
1120070GoodkNightPrisoner Challenge (IOI22_prison)C++17
80 / 100
8 ms1108 KiB
#include<bits/stdc++.h>
using namespace std;
const int x=23;

int pot[10];
vector<vector<int>> devise_strategy(int n){
    pot[0]=1;
    for(int i=1; i<10; i++) pot[i] = pot[i-1]*3;
    vector<vector<int>> w;
    w.resize(x);
    for(int i=0; i<x; i++) w[i].resize(n+1);
    for(int i=0; i<x; i++){
        if(i%6==0||i%6==4||i%6==5) w[i][0] = 0;
        else w[i][0] = 1;
    }
    for(int j=0; j<n; j++){
        w[0][j+1] = j/pot[7] + 1;
    }
    for(int i=1; i<x-4; i++){
        int ktora = (i+2)/3;
        int mod = (i+2)%3;
        int po = 8-ktora;
        for(int j=0; j<n; j++){
            int cyfra = (j/(pot[po]))%3;
            if(cyfra < mod){
                if(w[i][0]==1) w[i][j+1]=-2;
                else w[i][j+1]=-1;
            }
            if(cyfra > mod){
                if(w[i][0]==1) w[i][j+1]=-1;
                else w[i][j+1]=-2;               
            }
            if(cyfra==mod){
                w[i][j+1] = 3 * ktora + 1 + ((j/pot[po-1])%3);
            }
        }
    }
    for(int i=x-4; i<x-1; i++){
        int mod = (i+2)%3;
        for(int j=0; j<n; j++){
            int cyfra = (j%9)/3;
            if(cyfra < mod || ((cyfra==mod)&&j%3==0)){
                if(w[i][0]==1) w[i][j+1]=-2;
                else w[i][j+1]=-1;
            }
            if(cyfra > mod|| ((cyfra==mod)&&j%3==2)){
                if(w[i][0]==1) w[i][j+1]=-1;
                else w[i][j+1]=-2;               
            }
            if(cyfra == mod&&j%3==1){
                w[i][j+1]=x-1;
            }
        }
    }
    for(int j=0; j<n; j++){
        if(j%3==0) w[x-1][j+1] = -1;
        else w[x-1][j+1]=-2;
    }
    return w;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...