Submission #1056605

# Submission time Handle Problem Language Result Execution time Memory
1056605 2024-08-13T10:14:37 Z MercubytheFirst Prisoner Challenge (IOI22_prison) C++17
47 / 100
9 ms 1372 KB
#include "prison.h"
#include <bits/stdc++.h>
using namespace std;


const int B = 3;
const int x = 32;
const int L = 8;

int get_ith_dig(int n, int i) {
  for(int j = 0; j < i; ++j) {
    n /= B;
  }
  return n % B;
}

// [L][B]

vector<vector<int>> devise_strategy(int N) {
  vector<vector<int> > ans(x + 1, vector<int>(N + 1));
  ans[0][0] = 0;
  for(int i = 1; i <= N; ++i) {
    int dig = get_ith_dig(i, L - 1);
    ans[0][i] = (L - 1) * B + dig + 1;
  }
  for(int saw = 1; saw <= x; ++saw) {
    if(saw <= B*L) {
      int check_dig = (saw - 1) / B, a_dig = (saw - 1) % B;
      ans[saw][0] = 1;
      for(int inbag = 1; inbag <= N; ++inbag) {
        const int d = get_ith_dig(inbag, check_dig);
        if(d < a_dig) {
          ans[saw][inbag] = -2;
        }
        else if(d > a_dig) {
          ans[saw][inbag] = -1;
        }
        else {
          ans[saw][inbag] = B * L + check_dig;
        }
      }
    }
    else {
      int to_check = saw - B * L;
      ans[saw][0] = 0;
      for(int inbag = 1; inbag <= N; ++inbag) {
        ans[saw][inbag] = (to_check - 1) * B + get_ith_dig(inbag, to_check - 1) + 1;
      }
    }
  }
  // for(int i = 0; i <= x; ++i) {
  //   cout << i << " : ";
  //   for(int j = 0; j <= N; ++j) {
  //     cout << ans[i][j] << ' ';
  //   }cout << endl;
  // }
  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 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 2 ms 344 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 0 ms 348 KB Output is correct
4 Correct 1 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 348 KB Output is correct
8 Correct 0 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 344 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 4 ms 856 KB Output is partially correct
5 Partially correct 7 ms 1116 KB Output is partially correct
6 Partially correct 9 ms 1372 KB Output is partially correct
7 Partially correct 9 ms 1372 KB Output is partially correct
8 Partially correct 0 ms 348 KB Output is partially correct
9 Partially correct 1 ms 348 KB Output is partially correct
10 Partially correct 1 ms 348 KB Output is partially correct
11 Partially correct 4 ms 708 KB Output is partially correct
12 Partially correct 7 ms 1116 KB Output is partially correct