이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "prison.h"
#include <bits/stdc++.h>
using namespace std;
struct Range{
int l, r;
};
vector<vector<int>> devise_strategy(int N) {
const int k = 20;
vector<vector<int> > ret(k+1, vector<int>(N+1, -1));
for(auto &e : ret) e[0] = 0;
auto solve = [&](auto solve, int d, int val, int next_val, Range me, Range other) -> void {
//cerr << setw(2) << d << " " << setw(2) << val << " : " << me.l << " " << me.r << " / " << other.l << " " << other.r << "\n";
if(other.l > other.r) return;
ret[val][0] = d%2;
const int me_smaller = -1-(d%2);
const int other_smaller = -1-!(d%2);
for(int i = me.l; i <= other.l; ++i) ret[val][i] = me_smaller;
me.l = other.l + 1;
for(int i = other.r; i <= me.r; ++i) ret[val][i] = other_smaller;
me.r = other.r - 1;
if(me.l > me.r) return;
const int BLOCK = d < 6 ? 3 : d<7 ? 2 : 1;
vector<pair<int, Range> > subs(BLOCK);
for(int i=0; i<BLOCK; ++i){
subs[i].first = next_val + i;
subs[i].second.l = me.l + (i*(me.r-me.l+1)+BLOCK-1)/BLOCK;
subs[i].second.r = me.l + ((i+1)*(me.r-me.l+1)+BLOCK-1)/BLOCK - 1;
for(int j=subs[i].second.l; j<=subs[i].second.r; ++j){
ret[val][j] = subs[i].first;
}
}
for(auto &e : subs){
solve(solve, d+1, e.first, next_val + BLOCK, other, e.second);
}
};
solve(solve, 0, 0, 1, Range{1, N}, Range{1, N});
return ret;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |