# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1056300 | noyancanturk | Prisoner Challenge (IOI22_prison) | C++17 | 6 ms | 1232 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 "prison.h"
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
vector<vector<int>>devise_strategy(int N) {
int indexes[13][2];
int ind=1;
for(int i=12;1<i;i--){
indexes[i][0]=ind++;
indexes[i][1]=ind++;
}
vector<vector<int>>res(24);
ind=12;
int bag=0;
for(int i=0;i<21;i++){
if(i&1){
ind--;
bag=!bag;
}
res[i]=vector<int>(N+1);
res[i][0]=bag;
int mask=(1<<ind+1)-1;
for(int j=1;j<=N;j++){
if(i&&i==indexes[ind+1][0]&&(j&(1<<ind+1))){
if(bag){
res[i][j]=-1;
}else{
res[i][j]=-2;
}
}else if(i&&i==indexes[ind+1][1]&&!(j&(1<<ind+1))){
if(bag){
res[i][j]=-2;
}else{
res[i][j]=-1;
}
}else if((j&mask)==mask){
if(bag){
res[i][j]=-1;
}else{
res[i][j]=-2;
}
}else if((j&mask)==0){
if(bag){
res[i][j]=-2;
}else{
res[i][j]=-1;
}
}else{
res[i][j]=indexes[ind][(j>>ind)&1];
}
}
}
for(int i=21;i<23;i++){
if(i&1){
ind--;
bag=!bag;
}
res[i]=vector<int>(N+1);
res[i][0]=bag;
int mask=(1<<ind+1)-1;
assert(mask==3);
for(int j=1;j<=N;j++){
if(i&&i==indexes[ind+1][0]&&(j&(1<<ind+1))){
if(bag){
res[i][j]=-1;
}else{
res[i][j]=-2;
}
}else if(i&&i==indexes[ind+1][1]&&!(j&(1<<ind+1))){
if(bag){
res[i][j]=-2;
}else{
res[i][j]=-1;
}
}else if((j&mask)==mask){
if(bag){
res[i][j]=-1;
}else{
res[i][j]=-2;
}
}else if((j&mask)==0){
if(bag){
res[i][j]=-2;
}else{
res[i][j]=-1;
}
}else{
res[i][j]=23;
}
}
}
int i=23;
bag=!bag;
res[i]=vector<int>(N+1);
res[i][0]=bag;
int mask=(1<<ind+1)-1;
for(int j=1;j<=N;j++){
if(2<=(j&3)){
if(bag){
res[i][j]=-1;
}else{
res[i][j]=-2;
}
}else{
if(bag){
res[i][j]=-2;
}else{
res[i][j]=-1;
}
}
}
/*
for(int i=0;i<=23;i++){
for(int j=0;j<=N;j++){
cerr<<res[i][j]<<" ";
}cerr<<"\n";
}
*/
return res;
}
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... |