이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "prison.h"
#include <vector>
#include <bits/stdc++.h>
#define ll int
#define ln "\n"
using namespace std;
ll code(ll x, ll i){
string s = "";
while (x){
s+=to_string(x%3);
x/=3;
}
while (s.length()<8) s+='0';
reverse(s.begin(), s.end());
return s[i]-'0';
}
std::vector<std::vector<int>> devise_strategy(int N) {
vector<vector<ll>> ans(25, vector<ll>(N+1));
for (ll i=1; i<=N; i++){
ll cd=code(i, 0);
ans[0][i]=cd*8+1;
}
for (ll x=1; x<=24; x++){
if (x%2){
ans[x][0]=1;
ll pos=(x-1)%8, val=(x-1)/8;
for (ll i=1; i<=N; i++){
ll cd = code(i, pos);
if (cd>val) ans[x][i]=-1;
else if (cd<val) ans[x][i]=-2;
else {
if (pos+1==8) ans[x][i]=0;
else ans[x][i]=code(i, pos+1)*8+pos+2;
}
}
}else{
ans[x][0]=0;
ll pos=(x-1)%8, val=(x-1)/8;
for (ll i=1; i<=N; i++){
ll cd = code(i, pos);
if (cd>val) ans[x][i]=-2;
else if (cd<val) ans[x][i]=-1;
else {
if (pos+1==8) ans[x][i]=0;
else ans[x][i]=code(i, pos+1)*8+pos+2;
}
}
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |