Submission #849050

#TimeUsernameProblemLanguageResultExecution timeMemory
849050grossly_overconfidentPrisoner Challenge (IOI22_prison)C++17
30 / 100
22 ms2136 KiB
#include <bits/stdc++.h> using namespace std; int solve(int a){ return to_string(a).size(); } int find_digit(int a, int i){ return (to_string(a)[i] - 48); } vector<vector<int>> devise_strategy(int n){ int x = 50; vector<vector<int>> out(x, vector<int>(n + 1, 0)); for (int i = 1; i <= n; ++i){ out[0][i] = solve(i); } for (int i = 1; i <= 4; ++i){ out[i][0] = 1; for (int j = 1; j <= n; ++j){ if (solve(j) > i){ out[i][j] = -1; continue; } if (solve(j) < i){ out[i][j] = -2; continue; } out[i][j] = 10 + find_digit(j, 0); } } for (int i = 10; i <= 19; ++i){ out[i][0] = 0; for (int j = 1; j <= n; ++j){ int k = find_digit(j, 0); if (k > i - 10){ out[i][j] = -2; continue; } if (k < i - 10){ out[i][j] = -1; continue; } out[i][j] = 20 + find_digit(j, 1); } } for (int i = 20; i <= 29; ++i){ out[i][0] = 1; for (int j = 1; j <= n; ++j){ int k = find_digit(j, 1); if (k > i - 20){ out[i][j] = -1; continue; } if (k < i - 20){ out[i][j] = -2; continue; } out[i][j] = 30 + find_digit(j, 2); } } for (int i = 30; i <= 39; ++i){ out[i][0] = 0; for (int j = 1; j <= n; ++j){ int k = find_digit(j, 2); if (k > i - 30){ out[i][j] = -2; continue; } if (k < i - 30){ out[i][j] = -1; continue; } out[i][j] = 40 + find_digit(j, 3); } } for (int i = 40; i <= 49; ++i){ out[i][0] = 1; for (int j = 1; j <= n; ++j){ int k = find_digit(j, 3); if (k > i - 40){ out[i][j] = -1; continue; } if (k < i - 40){ out[i][j] = -2; } } } for (int i = 0; i < x; ++i){ for (int j = 0; j < n + 1; ++j){ if (out[i][j] < -2){ out[i][j] = 0; } } } return out; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...