Submission #762132

#TimeUsernameProblemLanguageResultExecution timeMemory
762132raysh07Prisoner Challenge (IOI22_prison)C++17
65 / 100
10 ms1108 KiB
#include "prison.h"
#include <bits/stdc++.h>
using namespace std;

vector<vector<int>> devise_strategy(int n) {
    vector<vector<int>> ans(25, vector<int>(n + 1));
    for (int i = 0; i <= 24; i++){
       // cout << i << " ";
        if (i == 0){
            int bit = 12;
           // cout << bit << " ";
            ans[i][0] = 0;
            for (int j = 1; j <= n; j++){
                ans[i][j] = 1 + (j >> bit & 1);
            }
        } else if (i % 4 == 1 || i % 4 == 2){
            int bit = 12 - (i - 1) / 2;
           // cout << bit << " ";
            ans[i][0] = 1;
            for (int j = 1; j <= n; j++){
                int a = (i % 4 == 2);
                int b = j >> bit & 1;
                
                if (a > b) ans[i][j] = -2;
                else if (a < b) ans[i][j] = -1;
                else {
                    int holy = bit - 1;
                    int x = i + 1;
                    if (i % 4 == 1) x++;
                    if (holy == 0){
                       if (j >> holy & 1) ans[i][j] = -1;
                       else ans[i][j] = -2;
                    } 
                    else 
                    ans[i][j] = x + (j >> holy & 1);
                }
            }
        } else {
            int bit = 12 - (i - 1) / 2;
           // cout << bit << " ";
            ans[i][0] = 0;
            for (int j = 1; j <= n; j++){
                int b = (i % 4 == 0);
                int a = j >> bit & 1;
                
                if (a > b) ans[i][j] = -2;
                else if (a < b) ans[i][j] = -1;
                else {
                    int holy = bit - 1;
                    int x = i + 1;
                    if (i % 4 == 3) x++;
                    if (holy == 0){
                        if (j >> holy & 1) ans[i][j] = -2;
                        else ans[i][j] = -1;
                    }
                    else 
                    ans[i][j] = x + (j >> holy & 1);
                }
            }
        }
        
        // for (int j = 0; j <= n; j++){
        //     cout << ans[i][j] << " \n"[j == n];
        // }
    }
    for (auto &x : ans) for (auto &y : x) if (y > 26) y = 0;
    
    // for (auto x : ans){
    //     for (auto y : x ) cout << y << " ";
    //     cout << "\n";
    // }
    return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...