Submission #907610

#TimeUsernameProblemLanguageResultExecution timeMemory
907610vjudge1Prisoner Challenge (IOI22_prison)C++17
0 / 100
1 ms348 KiB
#include "prison.h"
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define F first
#define S second
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;


const int BITS = 12;

const int A = -1;
const int B = -2;

int id(int bit, int state){
  if(bit==-1) return 0;
  bit=BITS-bit;
  return bit*2-state;
}

std::vector<std::vector<int>> devise_strategy(int N) {
  vector<vi> strat(2*BITS+1, vi(N+1));
  for(int b = BITS; b>=0; b--){
    rep(s,0,2){
      strat[id(b,s)][0] = b%2;
      if(b==BITS && s==1) continue;
      rep(o,1,N+1){
        if(o&(1<<b)){
          if(s || b==BITS){
            strat[id(b,s)][o]=id(b-1,1);
          }else{
            strat[id(b,s)][o]=b%2==0?A:B;
          }
        }else{
          if(s){
            strat[id(b,s)][o]=b%2==0?B:A;
          }else{
            strat[id(b,s)][o]=id(b-1,0);
          }
        }
      }
      // cout<<b<<" "<<s<<" ("<<id(b,s)<<"):";
      // rep(j,0,N+1) cout<<' ' << strat[id(b,s)][j];
      // cout<<endl;
    }
  }
  return strat;
}


// int main(){
//   devise_strategy(5000);
// }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...