Submission #1056300

#TimeUsernameProblemLanguageResultExecution timeMemory
1056300noyancanturkPrisoner Challenge (IOI22_prison)C++17
72 / 100
6 ms1232 KiB
#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)

prison.cpp: In function 'std::vector<std::vector<int> > devise_strategy(int)':
prison.cpp:25:21: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   25 |     int mask=(1<<ind+1)-1;
      |                  ~~~^~
prison.cpp:27:45: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   27 |       if(i&&i==indexes[ind+1][0]&&(j&(1<<ind+1))){
      |                                          ~~~^~
prison.cpp:33:52: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   33 |       }else if(i&&i==indexes[ind+1][1]&&!(j&(1<<ind+1))){
      |                                                 ~~~^~
prison.cpp:63:21: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   63 |     int mask=(1<<ind+1)-1;
      |                  ~~~^~
prison.cpp:66:45: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   66 |       if(i&&i==indexes[ind+1][0]&&(j&(1<<ind+1))){
      |                                          ~~~^~
prison.cpp:72:52: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   72 |       }else if(i&&i==indexes[ind+1][1]&&!(j&(1<<ind+1))){
      |                                                 ~~~^~
prison.cpp:99:19: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   99 |   int mask=(1<<ind+1)-1;
      |                ~~~^~
prison.cpp:99:7: warning: unused variable 'mask' [-Wunused-variable]
   99 |   int mask=(1<<ind+1)-1;
      |       ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...