Submission #632682

#TimeUsernameProblemLanguageResultExecution timeMemory
632682MojoLakePrisoner Challenge (IOI22_prison)C++17
38 / 100
19 ms1620 KiB
#include <iostream>
#include <vector>


using namespace std;

int max_dig = 12;
int x = 38;

bool at_b(int num){
  return num % 3 == 0 ? 0 : 1;
}

vector<vector<int>> devise_strategy(int n){

  vector<vector<int>> ret(x + 1, vector<int>(n+1));

  for(int i = 0; i <= x; ++i){
    for(int j = 0; j <= n; ++j){

      if(j == 0){
        ret[i][j] = at_b(i);
        continue;
      }

      if(i == 0){
        
        bool on = j & (1<<max_dig);
        ret[i][j] = on ? 2 : 1;
        continue;
      }

      if(!at_b(i)){
        //A
        int d = i / 3;
        int pos = max_dig - d;
        bool cur_on = j & (1<<pos);
        ret[i][j] = 3 * d + (cur_on ? 2 : 1);
      }

      else if(at_b(i)){
        //B
        bool prev_on = i % 3 == 1 ? 0 : 1;
        int d = i / 3;
        int pos = max_dig - d;
        bool cur_on = j & (1<<pos);

        if(prev_on != cur_on){
          ret[i][j] = prev_on ? -2 : -1;
        }

        else{
          ret[i][j] = 3 * (d + 1);
        }
      }

      else{
        cout << "something wrong\n";
      }

      ret[i][j] = min(x, ret[i][j]); 
    }
  }

  ret[0][0] = 0;

  return ret;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...