#include "prison.h"
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 1; i <= (n); ++i)
#define forn(i, l, r) for(int i = (l); (i) <= (r); ++i)
#define ford(i, r, l) for(int i = (r); (i) >= (l); --i)
#define endl "\n"
#define fi first
#define se second
#define pb push_back
#define pll pair<ll, ll>
#define pii pair<int, int>
#define all(a) a.begin(), a.end()
#define sz(a) (int)(a.size())
#define task "note"
template<typename T> bool maximize(T &res, const T &val) {if(res < val) {res = val; return 1;} return 0;}
template<typename T> bool minimize(T &res, const T &val) {if(res < val) return 0; res = val; return 1;}
inline int readInt() {char c;while(c=getchar(),c!='-'&&(c<'0'||c>'9'));bool sign=(c=='-');if(sign)c=getchar();int n=c-'0';while(c=getchar(),c>='0'&&c<='9')n=10*n+c-'0';return(!sign)?n:-n;}
inline ll readLong() {char c;while(c=getchar(),c!='-'&&(c<'0'||c>'9'));bool sign=(c=='-');if(sign)c=getchar();ll n=c-'0';while(c=getchar(),c>='0'&&c<='9')n=10*n+c-'0';return(!sign)?n:-n;}
inline string readString() {char c;while(c=getchar(),c==' '||c=='\n'||c=='\t');string s({c});while(c=getchar(),c!=EOF&&c!=' '&&c!='\n'&&c!='\t')s+=c;return s;}
const ll LINF = 1e3;
const ll K = 1e2 + 3;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int N = 1e5 + 3;
const int M = 15;
const int LIM = 14348907 + 3;
const ll INF = 1e18;
const int LOG = 12;
int n;
vector<vector<int>> devise_strategy(int N_)
{
n = N_;
vector<vector<int>> res(21, vector<int>(n + 1, 0));
function<void(int, int, int, int, int, int, int)> dnc =
[&](int depth, int id, int sz, int l, int r, int lb, int rb)
{
if(l > r) return;
// cout << depth << " " << id << " " << sz << " " << l << " " << r << " " << lb << " " << rb << endl;
++l; --r;
res[id][0] = depth & 1;
forn(i, lb, rb) if(i < l || i > r) res[id][i] = -((r < i) ^ (depth & 1)) - 1;
int num_sub = min(r - l + 1, 2 + (r - l + 1 > 4));
int len_sub = ceil(1.0 * (r - l + 1) / num_sub);
for(int cur_sub = 1, new_l = l; cur_sub <= num_sub; ++cur_sub)
{
int new_r = min(r, new_l + len_sub - 1);
forn(i, new_l, new_r) res[id][i] = sz + cur_sub;
dnc(depth + 1, sz + cur_sub, sz + num_sub, new_l, new_r, l - 1, r + 1);
new_l = new_r + 1;
}
};
dnc(0, 0, 0, 1, n, 1, n);
// for(auto u : res)
// {
// for(int v : u) cout << v << " "; cout << endl;
// }
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |