Submission #629153

#TimeUsernameProblemLanguageResultExecution timeMemory
629153handlenamePrisoner Challenge (IOI22_prison)C++17
0 / 100
0 ms212 KiB
#include <bits/stdc++.h> #include "prison.h" using namespace std; #define pb push_back #define mp make_pair int conv(int id){ if (id==0) return -1; return -2; } int numbitt(int x){ int res=0; while (x>0){ x/=3; res++; } return res; } int bitt(int x,int bit){ while (bit--) x/=3; return x%3; } vector<vector<int> > devise_strategy(int n){ int numbit=numbitt(n); vector<vector<int> > ans(numbit*3+1,vector<int>(n+1,0)); ans[0][0]=0; for (int j=1;j<=n;j++){ ans[0][j]=bitt(n,numbit-1)+1; } for (int i=1;i<(int)ans.size();i++){ int lol=(i+2)/3; if (lol%3==0) ans[i][0]=0; else ans[i][0]=1; int bit=numbit-lol; for (int j=1;j<=n;j++){ if ((i-1)%3<bitt(j,bit)){ ans[i][j]=conv(1-ans[i][0]); } else if ((i-1)%3>bitt(j,bit)){ ans[i][j]=conv(ans[i][0]); } else { if (bit==0){ ans[i][j]=0; continue; } ans[i][j]=lol*3+1+bitt(j,bit-1); } } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...