이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "prison.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> decompose(int x)
{
vector<int> digits;
for(int i = 0 ; i < 8 ; i++, x /= 3)
digits.push_back( x%3 );
reverse( digits.begin() , digits.end() );
return digits;
}
vector<vector<int>> devise_strategy(int N)
{
int n = N;
vector< vector<int> > v;
for(int i = 0 ; i < 6 ; i++)
{
int root = 4*i;
v.push_back( vector<int>(n + 1, 0) );
for(int j = 1 ; j <= n ; j++)
{
vector<int> d = decompose(j);
v[root][j] = root + d[i] + 1;
}
v.push_back( vector<int>(n + 1, 1) ); // r = 0
for(int j = 1 ; j <= n ; j++)
{
vector<int> d = decompose(j);
if( d[i] == 0 )
v[root + 1][j] = root + 4;
else
v[root + 1][j] = -1;
}
v.push_back( vector<int>(n + 1, 1) ); // r = 1
for(int j = 1 ; j <= n ; j++)
{
vector<int> d = decompose(j);
if( d[i] == 0 )
v[root + 2][j] = -2;
else if( d[i] == 1 )
v[root + 2][j] = root + 4;
else
v[root + 2][j] = -1;
}
v.push_back( vector<int>(n + 1, 1) ); // r = 2
for(int j = 1 ; j <= n ; j++)
{
vector<int> d = decompose(j);
if( d[i] == 2 )
v[root + 3][j] = root + 4;
else
v[root + 3][j] = -2;
}
}
int root = 4*6;
v.push_back( vector<int>(n + 1, 0) );
for(int j = 1 ; j <= n ; j++)
{
vector<int> d = decompose(j);
if( j%9 == 0 )
v[root][j] = -1;
else if( j%9 == 8 )
v[root][j] = -2;
else
v[root][j] = root + 1;
}
root++;
v.push_back( vector<int>(n + 1, 1) );
for(int j = 1 ; j <= n ; j++)
{
vector<int> d = decompose(j);
if( j%9 <= 1 )
v[root][j] = -2;
else if( j%9 >= 7 )
v[root][j] = -1;
else
v[root][j] = root + 1;
}
root++;
v.push_back( vector<int>(n + 1, 0) );
for(int j = 1 ; j <= n ; j++)
{
vector<int> d = decompose(j);
if( j%9 <= 2 )
v[root][j] = -1;
else if( j%9 >= 6 )
v[root][j] = -2;
else
v[root][j] = root + 1;
}
root++;
v.push_back( vector<int>(n + 1, 1) );
for(int j = 1 ; j <= n ; j++)
{
vector<int> d = decompose(j);
if( j%9 <= 3 )
v[root][j] = -2;
else if( j%9 >= 5 )
v[root][j] = -1;
else
v[root][j] = root + 1;
}
root++;
v.push_back( vector<int>(n + 1, 0) );
for(int j = 1 ; j <= n ; j++)
{
vector<int> d = decompose(j);
if( j%9 <= 4 )
v[root][j] = -1;
else if( j%9 >= 5 )
v[root][j] = -2;
}
return v;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |