# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
692875 | Pyqe | Prisoner Challenge (IOI22_prison) | C++17 | 13 ms | 1108 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>
#include "prison.h"
using namespace std;
const long long mm=8,z=22;
long long pw3[mm+1];
vector<vector<int>> devise_strategy(int n)
{
long long i,j,k,l,e,w,w2;
vector<int> cv;
vector<vector<int>> cvv;
pw3[0]=1;
for(i=1;i<=mm;i++)
{
pw3[i]=pw3[i-1]*3;
}
for(i=0;i<=z;i++)
{
k=mm-(i+2)/3;
l=-1;
if(k<mm)
{
if(!k)
{
l=1;
}
else
{
l=(i-1)%3;
}
}
e=k%2;
cv.clear();
cv.push_back(e);
for(j=1;j<=n;j++)
{
w=j/pw3[k]%3;
if(k-1>=0)
{
w2=j/pw3[k-1]%3;
}
if(l!=-1&&w!=l)
{
if(w<l)
{
cv.push_back(-1ll-e);
}
else
{
cv.push_back(-1ll-!e);
}
}
else if(k==1)
{
if(!w2)
{
cv.push_back(-1ll-e);
}
else if(w2==2)
{
cv.push_back(-1ll-!e);
}
else
{
cv.push_back((mm-k)*3+1);
}
}
else
{
cv.push_back(min((mm-k)*3+1+w2,z));
}
}
cvv.push_back(cv);
}
return cvv;
}
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... |