This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "prison.h"
// Made by TheQuantiX
#include <bits/stdc++.h>
//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2,sse4.2,bmi,bmi2,lzcnt,popcnt")
using namespace std;
using ll = long long;
constexpr ll MAXN = 1e5;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1000000000000000000LL;
ll tt, n, m, k, x, y, a, b, c, d;
std::vector<std::vector<int>> devise_strategy(int N) {
vector< vector<int> > ans(1, vector<int>(n + 1));
queue< pair< pair<int, int>, pair<int, int> > > q;
q.push({{0, 0}, {1, n}});
while (!q.empty()) {
auto p = q.front();
q.pop();
ll l = p.second.first;
ll r = p.second.first;
ll x = p.first.first;
ans[x][0] = p.first.second;
for (int i = 1; i <= l; i++) {
if (p.first.second == 0) {
ans[x][i] = -1;
}
else {
ans[x][i] = -2;
}
}
for (int i = r; i <= n; i++) {
if (p.first.second == 0) {
ans[x][i] = -2;
}
else {
ans[x][i] = -1;
}
}
l++;
r--;
if (l > r) {
continue;
}
int mid = (r + l) / 2;
q.push({{ans.size(), 1 - p.first.second}, {l, mid}});
ans.resize(ans.size() + 1);
if (l != r) {
q.push({{ans.size(), 1 - p.first.second}, {mid + 1, r}});
ans.resize(ans.size() + 1);
}
}
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... |