Submission #1029309

#TimeUsernameProblemLanguageResultExecution timeMemory
1029309AndreyPrisoner Challenge (IOI22_prison)C++17
0 / 100
5 ms860 KiB
#include "prison.h"
#include<bits/stdc++.h>
using namespace std;

bool yeah = true;

int calc(int a, int x) {
    a--;
    int r = 4999;
    yeah = true;
    for(int i = 0; i < x; i++) {
        if(a == 0) {
            yeah = false;
            return -1;
        }
        else if(a == r) {
            yeah = false;
            return 3;
        }
        r = ((r-1)/3);
        a--;
        a%=r+1;
    }
    r = ((r-1)/3);
    if(a == 0) {
            yeah = false;
        }
        else if(a == r) {
            yeah = false;
        }
    return a/(r+1);
}

vector<vector<int>> devise_strategy(int n) {
    vector<vector<int>> ans(30,vector<int> (n+1));
    ans[0][0] = 0;
    for(int i = 1; i <= n; i++) {
        if(i == 1) {
            ans[0][i] = -1;
        }
        else if(i == n) {
            ans[0][i] = -2;
        }
        else {
            ans[0][i] = calc(i,0)+1;
        }
    }
    for(int i = 1; i <= 26; i++) {
        int c = (i-1)/3+1;
        ans[i][0] = c%2;
        for(int j = 1; j <= n; j++) {
            if(calc(j,c-1) == (i-1)%3 && yeah) {
                ans[i][j] = c*3+calc(j,c)+1;
            }
            else {
                if(!yeah) {
                    if(calc(j,c) == -1) {
                        if(c%2) {
                            ans[i][j] = -2;
                        }
                        else {
                            ans[i][j] = -1;
                        }
                    }
                    else {
                        if(c%2) {
                            ans[i][j] = -1;
                        }
                        else {
                            ans[i][j] = -2;
                        }
                    }
                    continue;
                }
                if(calc(j,c-1) < (i-1)%3) {
                    if(c%2) {
                        ans[i][j] = -2;
                    }
                    else {
                        ans[i][j] = -1;
                    }
                }
                else {
                    if(c%2) {
                        ans[i][j] = -1;
                    }
                    else {
                        ans[i][j] = -2;
                    }
                }
            }
        }
    }
    return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...