Submission #856552

#TimeUsernameProblemLanguageResultExecution timeMemory
856552samek08Prisoner Challenge (IOI22_prison)C++17
80 / 100
10 ms1628 KiB
#include "prison.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define rep(a,b) for (int a = 0; a < (b); ++a) #define pb push_back #define all(t) t.begin(), t.end() const int MAXM = 22, POWSIZE = 10, MAXN = 5005; vector<vector<int>> wyn; int POW[POWSIZE]; int R[MAXN][8]; int convert_to[30]; int convert_from[30]; vector<vector<int>> devise_strategy(int N) { wyn.assign(MAXM+1,{}); rep(i,MAXM+1) wyn[i].assign(N+1,-1); POW[0] = 1; for(int i = 1; i < POWSIZE; ++i) POW[i] = POW[i-1] * 3; for(int i = 1; i <= 5000; ++i) { int akt = i; for(int j = 7; j >= 0; --j) { for(int k = 2; k > 0; --k) { if(POW[j]*k <= akt) { akt -= POW[j]*k; R[i][j] = k; break; } } } } for(int i = 2; i <= 8; ++i) { convert_to[i] = i-1, convert_from[i-1] = i; } for(int i = 11; i <= 18; ++i) { convert_to[i] = i-3, convert_from[i-3] = i; } for(int i = 22; i <= 28; ++i) { convert_to[i] = i-6, convert_from[i-6] = i; } wyn[0][0] = 0; for(int i = 1; i <= N; ++i) { int b = R[i][7]; wyn[0][i] = convert_to[10*b+8]; } for(int i = 1; i <= MAXM; ++i) { int akt = convert_from[i], bit_val = akt / 10, bit_idx = akt % 10; bool czy_pochodzi_z_A = false; if(bit_idx % 2 == 0) czy_pochodzi_z_A = true; if(czy_pochodzi_z_A) wyn[i][0] = 1; else wyn[i][0] = 0; for(int j = 1; j <= N; ++j) { int b = R[j][bit_idx-1]; if(bit_val < b) { if(czy_pochodzi_z_A) wyn[i][j] = -1; else wyn[i][j] = -2; } else if(bit_val > b) { if(czy_pochodzi_z_A) wyn[i][j] = -2; else wyn[i][j] = -1; } else { b = R[j][bit_idx-2]; if(bit_idx == 2) { if(b == 1) wyn[i][j] = convert_to[b*10+(bit_idx-1)]; else { if(czy_pochodzi_z_A) { if(b == 0) wyn[i][j] = -2; else wyn[i][j] = -1; } else { if(b == 0) wyn[i][j] = -1; else wyn[i][j] = -2; } } } else wyn[i][j] = convert_to[b*10+(bit_idx-1)]; } } } return wyn; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...