제출 #1225917

#제출 시각아이디문제언어결과실행 시간메모리
1225917the_coding_poohPrisoner Challenge (IOI22_prison)C++20
90 / 100
8 ms1096 KiB
#include "prison.h"
#include <bits/stdc++.h>
#define uwu return

using namespace std;

#define fs first
#define sc second

#define all(x) x.begin(), x.end()


void output(long long a, bool b){
    if(b)
        cerr << '\n';
    else
        cerr << a << ' ';
    return;
}

map <int, pair<int, int>> mp;

map <pair<int, int>, int> un_mp;

vector <int> magic;

void init(){
    mp[0] = {9, 0};
    mp[3] = {0, 1};
    mp[4] = {1, 0};
    mp[5] = {1, 1};
    mp[6] = {2, 0};
    mp[7] = {2, 1};
    mp[8] = {3, 0};
    mp[9] = {3, 1};
    mp[10] = {4, 0};
    mp[11] = {4, 1};
    mp[12] = {5, 0};
    mp[13] = {5, 1};
    mp[14] = {5, 2};
    mp[15] = {6, 0};
    mp[16] = {6, 1};
    mp[17] = {6, 2};
    mp[18] = {7, 0};
    mp[19] = {7, 1};
    mp[20] = {7, 2};
    mp[21] = {8, 0};
    mp[2] = {8, 1};
    mp[1] = {8, 2};
    magic = {1, 4, 8, 16, 32, 64, 192, 576, 1728, 5184, 114514};

    for(auto i:mp){
        un_mp[i.sc] = i.fs;
    }
    un_mp[{0, 0}] = -2;
    un_mp[{0, 3}] = -1;
    un_mp[{0, 2}] = 3;
    uwu;
}

vector<vector<int>> devise_strategy(int N) {
    init();
    vector<vector<int>> ret;
    for (int i = 0; i <= 21; i++){
        int lv = mp[i].fs;
        ret.push_back({lv & 1});
        for (int j = 1; j <= N; j++){
            int tmp = (j % magic[lv + 1]) / magic[lv];
            if(mp[i].sc == tmp){
                if(lv == 0){
                    if(tmp == 1)
                        ret.back().push_back(-1);
                    else
                        ret.back().push_back(-2);
                }
                else
                    ret.back().push_back(un_mp[{lv - 1, (j % magic[lv]) / magic[lv - 1]}]);
            }
            else{
                if(mp[i].sc > tmp)
                    ret.back().push_back(-(1 + (lv & 1)));
                else
                    ret.back().push_back(-(2 - (lv & 1)));
            }
        }
    }
    return ret;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...