# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
626504 | Kaitokid | Prisoner Challenge (IOI22_prison) | C++17 | 13 ms | 1244 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;
typedef long long ll;
vector<vector<int> > devise_strategy(int N)
{
int u=0;
int d=N;
while(d>1){u++;d/=2;}
vector<vector<int> > s(2*u+1,vector<int>(N+1,0));
for(int i=1;i<=u;i++)
{
if(i%2) s[i][0]=1;else s[i][0]=0;
for(int j=1;j<=N;j++)
if(j&(1<<i)){if(i%2)s[i][j]=-1;else s[i][j]=-2;}
else {if(j&(1<<(i-1)))s[i][j]=u+i-1;else s[i][j]=i-1;}
}
for(int i=1;i<=u;i++)
{
if(i%2) s[i+u][0]=1;else s[i+u][0]=0;
for(int j=1;j<=N;j++)
if(!(j&(1<<i))){if(i%2)s[i+u][j]=-2;else s[i+u][j]=-1;}
else {if(j&(1<<(i-1)))s[i+u][j]=u+i-1;else s[i+u][j]=i-1;}
}
for(int j=1;j<=N;j++)
if(s[1][j]>=0)
if(j&1)s[1][j]=-1;else s[1][j]=-2;
for(int j=1;j<=N;j++)
if(s[u+1][j]>=0)
if(j&1)s[u+1][j]=-1;else s[u+1][j]=-2;
if((u+1)%2)s[0][0]=1; else s[0][0]=0;
for(int j=1;j<=N;j++)
if(j&(1<<u))s[0][j]=2*u; else s[0][j]=u;
return s;
}/*
int main()
{
vector<vector<int> > v=devise_strategy(4);
cout<<v.size()<<endl;
for(int i=0;i<v.size();i++)
{
for(int j=0;j<v[i].size();j++)cout<<v[i][j]<<" ";
cout<<endl;
}
return 0;
}
*/
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... |