# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1060623 | 2024-08-15T19:25:21 Z | nvujica | Prisoner Challenge (IOI22_prison) | C++17 | 16 ms | 1116 KB |
#include <bits/stdc++.h> #include "prison.h" using namespace std; const int x = 21; vector<vector<int> > devise_strategy(int n) { vector <vector<int> > s(x + 1); for(int i = 0; i <= x; i++){ s[i].resize(n + 1, 0); } for(int i = 0; i <= x; i++){ int b, r; if(i <= 18){ b = (i + 2) / 3; r = (i + 2) % 3; } else if(i <= 20){ b = 7; r = (i + 1) % 2; } else { b = 8; } s[i][0] = b % 2; for(int val = 1; val <= n; val++){ vector <int> mask; int val2 = val; mask.push_back(val2 % 4); val2 /= 4; mask.push_back(val2 % 2); val2 /= 2; for(int j = 0; j < 6; j++){ mask.push_back(val2 % 3); val2 /= 3; } reverse(mask.begin(), mask.end()); if(b == 8){ if(mask[7] <= 1) s[i][val] = -1; else s[i][val] = -2; continue; } if(b == 0 || mask[b - 1] == r){ if(b == 7){ if(mask[b] == 0) s[i][val] = -2; else if(mask[b] == 3) s[i][val] = -1; else s[i][val] = 21; } else s[i][val] = b * 3 + 1 + mask[b]; } else if(mask[b - 1] < r){ s[i][val] = -1 - s[i][0]; } else if(mask[b - 1] > r) s[i][val] = -2 + s[i][0]; } } // for(int i = 0; i <= x; i++){ // for(int j = 0; j <= n; j++){ // cout << s[i][j] << ' '; // } // cout << endl; // } return s; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 344 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 2 ms | 348 KB | Output is correct |
6 | Correct | 2 ms | 344 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 3 ms | 348 KB | Output is correct |
9 | Correct | 2 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 2 ms | 344 KB | Output is correct |
5 | Correct | 2 ms | 432 KB | Output is correct |
6 | Correct | 2 ms | 344 KB | Output is correct |
7 | Correct | 1 ms | 344 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 2 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Partially correct | 0 ms | 348 KB | Output is partially correct |
3 | Partially correct | 0 ms | 348 KB | Output is partially correct |
4 | Partially correct | 8 ms | 604 KB | Output is partially correct |
5 | Partially correct | 13 ms | 860 KB | Output is partially correct |
6 | Partially correct | 16 ms | 1112 KB | Output is partially correct |
7 | Partially correct | 16 ms | 1116 KB | Output is partially correct |
8 | Partially correct | 0 ms | 348 KB | Output is partially correct |
9 | Partially correct | 2 ms | 344 KB | Output is partially correct |
10 | Partially correct | 3 ms | 384 KB | Output is partially correct |
11 | Partially correct | 7 ms | 604 KB | Output is partially correct |
12 | Partially correct | 13 ms | 856 KB | Output is partially correct |