이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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>;
vector<vector<int>> devise_strategy(int N) {
const int BIT_SIZE = 13;
vector<vector<int>> res(BIT_SIZE * 2, vector<int>(N + 1, 0));
res[0][0] = 0;
for (int ai = 1; ai <= N; ai++)
{
int bit = 1 << BIT_SIZE;
if ((ai & bit) == 0)
res[0][ai] = 1;
else
res[0][ai] = 2;
}
for (int order = 1; order <= BIT_SIZE - 2; order++)
{
res[order * 2 - 1][0] = res[order * 2][0] = order % 2;
int lbit = 1 << (BIT_SIZE - order + 1);
int bit = 1 << (BIT_SIZE - order);
int mine = order % 2 == 1 ? -2 : -1;
int other = order % 2 == 1 ? -1 : -2;
// order + 1번 비트가 같은지 보고 -> 다르면 order번 비트에 따라 다음 상태로 진행
for (int x = 1; x <= N; x++)
{
if ((x & lbit) == 0)
{
res[order * 2][x] = mine;
res[order * 2 - 1][x] = x & bit ? order * 2 + 2 : order * 2 + 1;
}
else
{
res[order * 2 - 1][x] = other;
res[order * 2][x] = x & bit ? order * 2 + 2 : order * 2 + 1;
}
}
}
{
int order = BIT_SIZE - 1;
res[order * 2 - 1][0] = order % 2;
int lbit = 1 << (BIT_SIZE - order + 1);
int bit = 1 << (BIT_SIZE - order);
int mine = order % 2 == 1 ? -2 : -1;
int other = order % 2 == 1 ? -1 : -2;
for (int x = 1; x <= N; x++)
{
if ((x & lbit) == 0)
{
res[order * 2][x] = mine;
res[order * 2 - 1][x] = (x & bit) ? order * 2 + 1 : mine;
}
else
{
res[order * 2 - 1][x] = other;
res[order * 2][x] = (x & bit) ? order * 2 + 1 : mine;
}
}
}
{
int order = BIT_SIZE;
res[order * 2 - 1][0] = order % 2;
int lbit = 1 << (BIT_SIZE - order + 1);
int bit = 1 << (BIT_SIZE - order);
int mine = order % 2 == 1 ? -2 : -1;
int other = order % 2 == 1 ? -1 : -2;
for (int x = 1; x <= N; x++)
{
if ((x & lbit) == 0)
{
res[order * 2 - 1][x] = mine;
}
else
{
res[order * 2 - 1][x] = (x & bit) ? other : mine;
}
}
}
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... |