#include "prison.h"
#include <vector>
#include<bits/stdc++.h>
using namespace std;
int power(int x) {
int ret = 1;
while(x--) ret *= 10;
return ret;
}
std::vector<std::vector<int>> devise_strategy(int N) {
vector<vector<int>> ret(50, vector<int>(N+1, 0));
ret[0][0] = 0;
for(int k=1;k<=N;k++) {
ret[0][k] = 10+(k/1000);
}
for(int i=1;i<=4;i++) {
for(int j=0;j<10;j++) {
ret[(i*10)+j][0] = i%2;
for(int k=1;k<=N;k++) {
int dig = (k/power(4-i))%10;
if(dig>j) {
if(i%2) ret[(i*10)+j][k] = -1;
else ret[(i*10)+j][k] = -2;
} else if(dig<j) {
if(i%2) ret[(i*10)+j][k] = -2;
else ret[(i*10)+j][k] = -1;
} else {
if(i<4) ret[(i*10)+j][k] = ((i+1)*10)+((k/power(3-i))%10);
}
}
}
}
return ret;
}
# |
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 |
2 ms |
348 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 |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
2 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 |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
2 ms |
604 KB |
Output is correct |
6 |
Correct |
2 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 |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
9 ms |
1112 KB |
Output is partially correct |
5 |
Partially correct |
21 ms |
1628 KB |
Output is partially correct |
6 |
Partially correct |
21 ms |
1884 KB |
Output is partially correct |
7 |
Partially correct |
20 ms |
1884 KB |
Output is partially correct |
8 |
Partially correct |
0 ms |
348 KB |
Output is partially correct |
9 |
Partially correct |
2 ms |
348 KB |
Output is partially correct |
10 |
Partially correct |
3 ms |
604 KB |
Output is partially correct |
11 |
Partially correct |
8 ms |
860 KB |
Output is partially correct |
12 |
Partially correct |
16 ms |
1628 KB |
Output is partially correct |