# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
828271 | Amylopectin | Prisoner Challenge (IOI22_prison) | C++17 | 17 ms | 1492 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 <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int mxn = 1e5 + 10;
int thr[mxn] = {};
vector<int> fa;
vector<vector<int> > ans;
std::vector<std::vector<int>> devise_strategy(int n)
{
int i,j,cn,cm,fn,fm,cou = 7;
thr[0] = 1;
for(i=1; i<10; i++)
{
thr[i] = thr[i-1] * 3;
}
cou = 7;
fa.push_back(0);
for(i=1; i<=n; i++)
{
fa.push_back(1+(i/thr[cou]));
}
ans.push_back(fa);
cou = 8;
for(i=1; i<19; i++)
{
fa.clear();
if(i%3 == 1)
{
cou --;
}
cm = (i-1) % 3;
if(((i-1)/3) % 2 == 0)
{
fa.push_back(1);
for(j=1; j<=n; j++)
{
cn = (j % thr[cou+1]) / thr[cou];
if(cn < cm)
{
fa.push_back(-2);
}
else if(cn > cm)
{
fa.push_back(-1);
}
else
{
fn = (j % thr[cou]) / thr[cou-1];
fa.push_back(i-cm + 3 + fn);
}
}
}
else
{
fa.push_back(0);
for(j=1; j<=n; j++)
{
cn = (j % thr[cou+1]) / thr[cou];
if(cn < cm)
{
fa.push_back(-1);
}
else if(cn > cm)
{
fa.push_back(-2);
}
else
{
fn = (j % thr[cou]) / thr[cou-1];
fa.push_back(i-cm + 3 + fn);
}
}
}
ans.push_back(fa);
}
for(i=0; i<3; i++)
{
fa.clear();
fa.push_back(1);
cm = i;
for(j=1; j<=n; j++)
{
cn = (j % thr[2]) / thr[1];
if(cn < cm)
{
fa.push_back(-2);
}
else if(cn > cm)
{
fa.push_back(-1);
}
else
{
fn = (j % thr[1]) / thr[0];
if(fn == 0)
{
fa.push_back(-2);
}
else if(fn == 2)
{
fa.push_back(-1);
}
else
{
fa.push_back(22);
}
}
}
ans.push_back(fa);
}
fa.clear();
fa.push_back(0);
for(j=1; j<=n; j++)
{
if(j%3 == 0)
{
fa.push_back(-1);
}
else
{
fa.push_back(-2);
}
}
ans.push_back(fa);
return {ans};
}
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... |