Submission #856550

#TimeUsernameProblemLanguageResultExecution timeMemory
856550samek08Prisoner Challenge (IOI22_prison)C++17
65 / 100
11 ms1880 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 = 24, POWSIZE = 10, MAXN = 5005; vector<vector<int>> wyn; int POW[POWSIZE]; int R[MAXN][8]; 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; } } } } wyn[0][0] = 0; for(int i = 1; i <= N; ++i) { int b = R[i][7]; wyn[0][i] = 10*b+8; wyn[0][i] -= wyn[0][i]/10*2; } for(int i = 1; i <= MAXM; ++i) { int akt = i; if(i >= 9 and i <= 16) akt += 2; else if (i >= 17 and i <= 24) akt += 4; int 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]; wyn[i][j] = b*10+(bit_idx-1); wyn[i][j] -= wyn[i][j]/10*2; } } } /* for (int i = 0; i <= MAXM; ++i) { for (int j = 0; j <= N; ++j) cout << wyn[i][j] << " "; cout << endl; } */ return wyn; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...