이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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()
struct Przedzial
{
int l,p, idx;
};
const int MAXM = 23;
vector<vector<int>> wyn;
inline Przedzial zejdz(int l, int p, int idx)
{
if (l+1 == p)
{
if(idx == l) return {l,l,1};
return {p,p,2};
}
int s = (p-l+1) / 3;
if((p-l+1) % 3 == 0 or (p-l+1) % 3 == 1)
{
if(idx <= l+s-1) return {l,l+s-1,1};
else if(idx <= l+2*s-1) return {l+s,l+2*s-1,2};
else return {l+2*s,p,3};
}
else
{
if(idx <= l+s-1) return {l,l+s-1,1};
else if(idx <= l+2*s) return {l+s,l+2*s,2};
else return {l+2*s+1,p,3};
}
}
vector<vector<int>> devise_strategy(int N)
{
wyn.assign(MAXM+1,{});
rep(i,MAXM+1) wyn[i].assign(N+1,-1);
wyn[0][0] = 0;
for(int i = 1; i <= N; ++i)
{
if(i == 1) wyn[0][i] = -1;
else if (i == N) wyn[0][i] = -2;
else wyn[0][i] = zejdz(1,N,i).idx;
}
for(int i = 1; i <= MAXM; ++i)
{
for(int j = 1; j <= N; ++j)
{
int ile = (i-1) / 3 + 1, gdzie_zeszlem = i % 3;
if(gdzie_zeszlem == 0) gdzie_zeszlem = 3;
bool czy_pochodze_z_A = true;
if(ile % 2 == 0) czy_pochodze_z_A = false;
if(czy_pochodze_z_A) wyn[i][0] = 1;
else wyn[i][0] = 0;
Przedzial akt = {1,N};
rep(k,ile) akt = zejdz(akt.l, akt.p, j);
if(akt.idx < gdzie_zeszlem)
{
if(czy_pochodze_z_A) wyn[i][j] = -2;
else wyn[i][j] = -1;
}
else if (akt.idx > gdzie_zeszlem)
{
if(czy_pochodze_z_A) wyn[i][j] = -1;
else wyn[i][j] = -2;
}
else
{
if(akt.l == akt.p)
{
if(czy_pochodze_z_A) wyn[i][j] = -1;
else wyn[i][j] = -2;
}
else if(akt.l == j)
{
if(czy_pochodze_z_A) wyn[i][j] = -2;
else wyn[i][j] = -1;
}
else if(akt.p == j)
{
if(czy_pochodze_z_A) wyn[i][j] = -1;
else wyn[i][j] = -2;
}
else
{
akt = zejdz(akt.l, akt.p,j);
if(akt.l == akt.p and akt.idx == 1)
{
if(czy_pochodze_z_A) wyn[i][j] = -2;
else wyn[i][j] = -1;
}
else if(akt.l == akt.p and akt.idx == 3)
{
if(czy_pochodze_z_A) wyn[i][j] = -1;
else wyn[i][j] = -2;
}
else
{
wyn[i][j] = ile*3+akt.idx;
if(wyn[i][j] == 23) wyn[i][j] = 22;
}
}
}
}
}
/*
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... |