Submission #661186

#TimeUsernameProblemLanguageResultExecution timeMemory
661186mychecksedadPrisoner Challenge (IOI22_prison)C++17
100 / 100
11 ms1004 KiB
#include <bits/stdc++.h> using namespace std; vector<vector<int>> devise_strategy(int n){ int d[10] = {3, 3, 3, 3, 3, 2, 2, 1, 1, 1}; int p[21], pp[21], pref[8] = {0, 3, 6, 9, 12, 15, 17, 19}; p[0] = pp[0] = 0; for(int i = 0, cur = 0; i <= 20; cur++){ for(int j = i + 1; j <= i + d[cur]; ++j){ p[j] = cur + 1; pp[j] = j - i - 1; } i += d[cur]; } int b = 8; vector<string> dp; function<void(int, string)> generate = [&](int depth, string str){ dp.push_back(str + string(b - depth + 1, 'L')); if(depth < b){ for(char i = '0'; i < d[depth] + '0'; ++i){ generate(depth + 1, str + i); } } dp.push_back(str + string(b - depth + 1, 'R')); }; generate(0, ""); vector<vector<int>> v(21); for(int i = 0; i <= 20; ++i) v[i].resize(n + 1); for(int i = 0; i <= 20; ++i){ int s = p[i], t = pp[i]; v[i][0] = (s % 2); // s is even: A, s is odd: B for(int j = 1; j <= n; ++j){ if(s == 0){ if(dp[j][s] == 'L'){ v[i][j] = -1; }else if(dp[j][s] == 'R'){ v[i][j] = -2; }else{ v[i][j] = pref[s] + 1 + (dp[j][s] - '0'); } }else if(s % 2){ int abit = t; int bbit = dp[j][s - 1] - '0'; if(dp[j][s - 1] == 'R'){ v[i][j] = -1; }else if(dp[j][s - 1] == 'L'){ v[i][j] = -2; }else if(abit < bbit){ v[i][j] = -1; }else if(bbit < abit){ v[i][j] = -2; }else if(dp[j][s] == 'L'){ v[i][j] = -2; }else if(dp[j][s] == 'R'){ v[i][j] = -1; }else{ v[i][j] = pref[s] + 1 + (dp[j][s] - '0'); } }else{ int abit = dp[j][s - 1] - '0'; int bbit = t; if(dp[j][s - 1] == 'L'){ v[i][j] = -1; }else if(dp[j][s - 1] == 'R'){ v[i][j] = -2; }else if(abit < bbit){ v[i][j] = -1; }else if(bbit < abit){ v[i][j] = -2; }else if(dp[j][s] == 'L'){ v[i][j] = -1; }else if(dp[j][s] == 'R'){ v[i][j] = -2; }else{ v[i][j] = pref[s] + 1 + (dp[j][s] - '0'); } } } } return v; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...