이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
std::vector<std::vector<int>> devise_strategy(int N){
vector ans(22, vector (N+1, 0));
vector<vector<pair<int,int>>> rgs(22);
rgs[0].push_back(make_pair(1,5000));
vector<pair<int,int>> curr; curr.push_back(make_pair(1,5000));
vector<pair<int,int>> nc;
for (int i=0; i<7; i++) {
for (auto [l,r]: curr) {
l++; r--;
rgs[3*i+1].push_back({l, (2*l+r)/3});
nc.push_back({l, (2*l+r)/3});
}
for (auto [l,r]: curr) {
l++; r--;
rgs[3*i+2].push_back({(2*l+r)/3 + 1, (l+2*r)/3});
nc.push_back({(2*l+r)/3 + 1, (l+2*r)/3});
}
for (auto [l,r]: curr) {
l++; r--;
rgs[3*i+3].push_back({(l+2*r)/3+1, r});
nc.push_back({(l+2*r)/3+1, r});
}
curr = nc; nc.clear();
}
ans[0][0] = 0; ans[0][1] = -1; ans[0][N] = -2;
for (int i=2; i<N; i++) {
for (auto [l,r]: rgs[1]) {
if (l<=i && i<=r) ans[0][i] = 1;
}
for (auto [l,r]: rgs[3]) {
if (l<=i && i<=r) ans[0][i] = 3;
}
for (auto [l,r]: rgs[2]) {
if (l<=i && i<=r) ans[0][i] = 2;
}
}
for (int i=1; i<22; i++) {
int pl = (i-1)/3 % 2;
int bl = (i-1)/3; int first_pr = (i-1) % 3;
ans[i][0] = !pl;
int ll = rgs[bl*3 + 1][0].first; int rr = rgs[bl*3+3].back().second;
for (int j=1; j<=N; j++) {
int sec_pr = -1;
int on_lf =0, on_rg =0;
for (auto [l,r]: rgs[bl*3 + 1]) {
if (l<=j && j<=r) {
sec_pr = 0;
}
if (l==j) on_lf = 1; if (j==r) on_rg = 1;
}
for (auto [l,r]: rgs[bl*3 + 2]) {
if (l<=j && j<=r) {
sec_pr = 1;
}
if (l==j) on_lf = 1; if (j==r) on_rg = 1;
}
for (auto [l,r]: rgs[bl*3 + 3]) {
if (l<=j && j<=r) {
sec_pr = 2;
}
if (l==j) on_lf = 1; if (j==r) on_rg = 1;
}
if (sec_pr == -1) {
if (j <= ll) ans[i][j] = -1 -!pl;
if (j >= rr) ans[i][j] = -1 - pl;
} else {
if (first_pr == sec_pr) {
ans[i][j] = bl*3 + 4 + sec_pr;
if (ans[i][j] >= 22) ans[i][j] = -1;
if (on_lf) ans[i][j] = -1-!pl;
if (on_rg) ans[i][j] = -1 - pl;
}
if (first_pr < sec_pr) ans[i][j] = -1 -pl;
if (first_pr > sec_pr) ans[i][j] = -1 - !pl;
}
}
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
prison.cpp: In function 'std::vector<std::vector<int> > devise_strategy(int)':
prison.cpp:54:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
54 | if (l==j) on_lf = 1; if (j==r) on_rg = 1;
| ^~
prison.cpp:54:26: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
54 | if (l==j) on_lf = 1; if (j==r) on_rg = 1;
| ^~
prison.cpp:60:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
60 | if (l==j) on_lf = 1; if (j==r) on_rg = 1;
| ^~
prison.cpp:60:26: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
60 | if (l==j) on_lf = 1; if (j==r) on_rg = 1;
| ^~
prison.cpp:67:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
67 | if (l==j) on_lf = 1; if (j==r) on_rg = 1;
| ^~
prison.cpp:67:26: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
67 | if (l==j) on_lf = 1; if (j==r) on_rg = 1;
| ^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |