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 <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>
#include <math.h>
#include <random>
#include <functional>
#include <assert.h>
#include <math.h>
#define all(x) (x).begin(), (x).end()
#define xx first
#define yy second
using namespace std;
template<typename T, typename Pr = less<T>>
using pq = priority_queue<T, vector<T>, Pr>;
using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;
void dfs(vector<vector<int>>& res, int n, int now, int turn, int l, int r)
{
int other = (turn + 1) % 2;
int lx = l + 1;
int rx = r - 1;
int m = (lx + rx) / 2;
res[now][0] = turn;
int lo = res.size();
int hi = res.size() + 1;
for (int i = 1; i <= n; i++)
{
if (i <= l)
{
res[now][i] = -(turn + 1);
continue;
}
if (i >= r)
{
res[now][i] = -(other + 1);
continue;
}
if (i <= m)
{
res[now][i] = lo;
continue;
}
res[now][i] = hi;
}
if (lx > rx)
return;
res.push_back(vector<int>(n + 1, 0));
dfs(res, n, lo, (turn + 1) % 2, lx, m);
if (m + 1 <= rx)
{
res.push_back(vector<int>(n + 1, 0));
dfs(res, n, hi, (turn + 1) % 2, m + 1, rx);
}
}
vector<vector<int>> devise_strategy(int N)
{
vector<vector<int>> res;
res.push_back(vector<int>(N + 1, 0));
dfs(res, N, 0, 0, 1, N);
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... |