#include "prison.h"
#include <bits/stdc++.h>
using namespace std;
std::vector<std::vector<int>> devise_strategy (int n) {
vector < vector < int > > ans (25, vector < int > (n + 1));
vector < int > mp (25);
for (int i = 0, j = 0; i < 25; ++i)
{
if (i == 1 || i == 3) continue;
mp[i] = j++;
}
mp[1] = mp[3] = -1;
for (int i = 0; i < 8; ++i)
for (int j = 0; j < 3; ++j)
{
int k = mp[i * 3 + j + 1];
if (k == -1) continue;
ans[k][0] = i % 2;
for (int m = 1; m <= n; ++m)
{
int p = m;
for (int q = 0; q < i; ++q) p /= 3;
p %= 3;
if (p < j) ans[k][m] = -1 - (i % 2);
else if (p > j) ans[k][m] = -2 + (i % 2);
else
{
if (i == 0) continue;
p = m;
for (int q = 0; q < i - 1; ++q) p /= 3;
p %= 3;
if (i == 1 && p != 1)
{
if (p == 2) ans[k][m] = -2 + (i % 2);
else ans[k][m] = -1 - (i % 2);
}
else ans[k][m] = mp[(i - 1) * 3 + p + 1];
}
}
}
ans[0][0] = 8 % 2;
for (int m = 1; m <= n; ++m)
{
int p = m;
for (int q = 0; q < 7; ++q) p /= 3;
p %= 3;
ans[0][m] = mp[7 * 3 + p + 1];
}
// ans.erase (ans.begin () + 3);
// ans.erase (ans.begin () + 1);
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
464 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
600 KB |
Output is correct |
2 |
Partially correct |
1 ms |
348 KB |
Output is partially correct |
3 |
Partially correct |
1 ms |
344 KB |
Output is partially correct |
4 |
Partially correct |
5 ms |
604 KB |
Output is partially correct |
5 |
Partially correct |
9 ms |
1116 KB |
Output is partially correct |
6 |
Partially correct |
10 ms |
1116 KB |
Output is partially correct |
7 |
Partially correct |
10 ms |
1116 KB |
Output is partially correct |
8 |
Partially correct |
1 ms |
348 KB |
Output is partially correct |
9 |
Partially correct |
1 ms |
348 KB |
Output is partially correct |
10 |
Partially correct |
2 ms |
348 KB |
Output is partially correct |
11 |
Partially correct |
4 ms |
780 KB |
Output is partially correct |
12 |
Partially correct |
8 ms |
904 KB |
Output is partially correct |