Submission #632165

#TimeUsernameProblemLanguageResultExecution timeMemory
632165CauchicoPrisoner Challenge (IOI22_prison)C++17
0 / 100
1 ms212 KiB
#include <bits/stdc++.h> using namespace std; vector<vector<int>> devise_strategy(int n) { int x = 3 * ceil(log2(n)/(float(log2(3)))) - 2; //cout << x << "\n"; vector<vector<int>> ans(x+1,vector<int>(n+1)); vector<int> p = {1}; while (3*p.back() <= n) { p.push_back(3*p.back()); } ans[0][0] = 0; for (int j=1;j<=n;j++) { ans[0][j] = 1 + j/p.back(); } for (int i=1;i<x;i++) { ans[i][0] = !(((i-1)/3)&1); for (int j=1;j<=n;j++) { int r = (j/p.back())%3 + 1; if (r == i%3) { int val = 3 + (i- i%3) + 1 + (j/p[p.size()-2])%3; if (val < x) { ans[i][j] = val; } else if (val == x) { ans[i][j] = -(ans[i][0]+1); } else if (val == x+1) { ans[i][j] = x; } else { ans[i][j] = -(!ans[i][0]+1); } } else if (r < i%3) { ans[i][j] = -(ans[i][0]+1); } else { ans[i][j] = -(!ans[i][0]+1); } } if (i%3==0) p.pop_back(); } ans[x][0] = !(((x-1)/3)&1); for (int j=1;j<=n;j++) { if ((j%3) == 0) { ans[x][j] = -(ans[x][0]+1); } else { ans[x][j] = -(!ans[x][0]+1); } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...