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;
typedef long long ll;
typedef long double ld;
#define rep(a,b) for (int a = 0; a < (b); ++a)
#define pb push_back
#define all(t) t.begin(), t.end()
const int MAXM = 26, POWSIZE = 10, MAXN = 5005;
vector<vector<int>> wyn;
int POW[POWSIZE];
int R[MAXN][8];
vector<vector<int>> devise_strategy(int N)
{
wyn.assign(MAXM+1,{});
rep(i,MAXM+1) wyn[i].assign(N+1,-1);
POW[0] = 1;
for(int i = 1; i < POWSIZE; ++i) POW[i] = POW[i-1] * 3;
for(int i = 1; i <= 5000; ++i)
{
int akt = i;
for(int j = 7; j >= 0; --j)
{
for(int k = 2; k > 0; --k)
{
if(POW[j]*k <= akt)
{
akt -= POW[j]*k;
R[i][j] = k;
break;
}
}
}
}
wyn[0][0] = 0;
for(int i = 1; i <= N; ++i)
{
int b = R[i][7];
wyn[0][i] = 10*b+8;
wyn[0][i] -= wyn[0][i]/10*2;
}
for(int i = 1; i <= MAXM; ++i)
{
int akt = i;
if(i % 10 == 0 or i % 10 == 9) akt += 2;
int bit_val = akt / 10, bit_idx = akt % 10;
bool czy_pochodzi_z_A = false;
if(bit_idx % 2 == 0) czy_pochodzi_z_A = true;
if(czy_pochodzi_z_A) wyn[i][0] = 1;
else wyn[i][0] = 0;
for(int j = 1; j <= N; ++j)
{
int b = R[j][bit_idx-1];
if(bit_val < b)
{
if(czy_pochodzi_z_A) wyn[i][j] = -1;
else wyn[i][j] = -2;
}
else if(bit_val > b)
{
if(czy_pochodzi_z_A) wyn[i][j] = -2;
else wyn[i][j] = -1;
}
else
{
b = R[j][bit_idx-2];
wyn[i][j] = b*10+(bit_idx-1);
wyn[i][j] -= wyn[i][j]/10*2;
}
}
}
/*
for (int i = 0; i <= MAXM; ++i)
{
for (int j = 0; j <= N; ++j) cout << wyn[i][j] << " ";
cout << endl;
}
*/
return wyn;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |