# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
742991 | merlin | Prisoner Challenge (IOI22_prison) | C++17 | 14 ms | 1176 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
//https://ioi.contest.codeforces.com/group/32KGsXgiKA/contest/103877/problem/B
void setIO(string name="") {
cin.tie(0)->sync_with_stdio(0);
if (!name.empty()) {
freopen((name+".in").c_str(), "r", stdin);
freopen((name+".out").c_str(), "w", stdout);
}
}
vector<vector<int>> devise_strategy(int n){
const int maxBit = 12;
//int maxBit = 1;
//while(1<<maxBit <= n) maxBit++;
//maxBit--;
vector<vector<int>> ans(2*maxBit+2,vector<int>(n+1));
for(int i = 1;i<2*maxBit+2;i++){
int cur_bit = (i)/2;
for(int j = 1;j<=n;j++){
int set_b = j & (1<<cur_bit);
if((set_b != 0 && i%2) || (set_b == 0 && i%2 == 0)){ //ak nechcem odpovedat
ans[i][j] = 2*(cur_bit - 1);
if(j & 1<<(cur_bit - 1)) ans[i][j]++;
}else{ //idem odpovedat
if(1 - (maxBit - cur_bit)%2){ //posledne som meral B
if(i%2 == 0 && set_b){
ans[i][j] = -1;
}else{
ans[i][j] = -2;
}
}else{ //posledne som meral A
if(i%2 == 0 && set_b){
ans[i][j] = -2;
}else{
ans[i][j] = -1;
}
}
}
if(ans[i][j] == 0) ans[i][j] = -1;
}
ans[i][0] = 1 - (maxBit - cur_bit)%2;
//ans[i][0] = cur_bit;
}
for(int j = 1;j<=n;j++){
ans[0][j] = 2*maxBit;
if(j & (1<<maxBit)) ans[0][j] ++;
}
ans[0][0] = 0;
ans[0][1] = -1;
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |