Submission #938438

# Submission time Handle Problem Language Result Execution time Memory
938438 2024-03-05T06:35:05 Z Trisanu_Das Prisoner Challenge (IOI22_prison) C++17
100 / 100
9 ms 1372 KB
#include "prison.h"
#include <bits/stdc++.h>
using namespace std;
 
vector<vector<int>> ans;
 
void dnc(int P,int A,int B,int LL,int RR, int L,int R) {
  for (int i = L; i <= R; i++) ans[P][i] = A*3+B;
  for (int i = LL; i <= L; i++) ans[A*3+B][i] = -1 - ans[A*3+B][0];
  for (int i = R; i <= RR; i++) ans[A*3+B][i] = -2 + ans[A*3+B][0];
  L++; R--;
  if (R - L < 0) return;
  if (R - L < 2) {
    dnc(A*3+B, A+1, 1, L-1, R+1, L, R);
    return;
  }
  if (R - L < 4) {
    dnc(A*3+B, A+1, 1, L-1, R+1, L, (L+R)/2);
    dnc(A*3+B, A+1, 2, L-1, R+1, (L+R)/2+1, R);
    return;
  }
  dnc(A*3+B, A+1, 1, L-1, R+1, L, (L+L+R)/3);
  dnc(A*3+B, A+1, 2, L-1, R+1, (L+L+R)/3+1, (L+R+R)/3);
  dnc(A*3+B, A+1, 3, L-1, R+1, (L+R+R)/3+1, R);
}
 
vector<vector<int>> devise_strategy(int N) {
  for (int i = 0; i <= 20; i++) {
    ans.push_back(vector<int>(N+1,0));
    if ((i + 2) % 6 < 3) ans[i][0] = 1;
  }
  dnc(0, -1, 3, 1, N, 1, N);
  return ans;
}
# 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 1 ms 348 KB Output is correct
5 Correct 1 ms 360 KB Output is correct
6 Correct 1 ms 504 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 344 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 348 KB Output is correct
5 Correct 1 ms 440 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 436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 0 ms 436 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 4 ms 896 KB Output is correct
5 Correct 7 ms 1116 KB Output is correct
6 Correct 8 ms 1372 KB Output is correct
7 Correct 9 ms 1368 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 4 ms 860 KB Output is correct
12 Correct 7 ms 1112 KB Output is correct