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 <bits/stdc++.h>
using namespace std;
#define st first
#define nd second
vector<vector<int>> devise_strategy(int N)
{
int n=N;
vector<pair<int,int>>a(23);a={{0,0},{1,0},{2,0},{3,0},{4,0},{5,0},{6,0},{7,0},{1,1},{2,1},{3,1},{4,1},{5,1},{6,1},
{7,1},{8,1},{1,2},{2,2},{3,2},{4,2},{5,2},{6,2},{7,2}};
vector<vector<int>> b(23,vector<int>(n+1));
vector<vector<int>>t(n+1,vector<int>(9));
for(int i=0;i<t.size();i++)
{
t[i][8]=i;
for(int j=8;j>0;j--)
{
t[i][j-1]=t[i][j]/3;
t[i][j]%=3;
}
}
for(int i=0;i<23;i++)
{
b[i][0]=a[i].st%2;
for(int j=1;j<=n;j++)
{
if(a[i].nd>t[j][a[i].st])
{
b[i][j]=b[i][0]*(-1)-1;
}
if(a[i].nd<t[j][a[i].st])
{
b[i][j]=b[i][0]-2;
}
if(a[i].nd==t[j][a[i].st])
{
if(t[j][a[i].st+1]==0)
{
b[i][j]=a[i].st+1;
if(a[i].st+1==8)
{
b[i][j]=b[i][0]*(-1)-1;
}
}
if(t[j][a[i].st+1]==1)
{
b[i][j]=a[i].st+8;
}
if(t[j][a[i].st+1]==2)
{
b[i][j]=a[i].st+16;
if(a[i].st+1==8)
{
b[i][j]=b[i][0]-2;
}
}
}
}
}
return b;
}
Compilation message (stderr)
prison.cpp: In function 'std::vector<std::vector<int> > devise_strategy(int)':
prison.cpp:15:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
15 | for(int i=0;i<t.size();i++)
| ~^~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |