제출 #628140

#제출 시각아이디문제언어결과실행 시간메모리
628140jwvg0425죄수들의 도전 (IOI22_prison)C++17
56 / 100
15 ms1148 KiB
#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 + 1, 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; 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;

				// order에 따라 다음 상태 설정
				if (order == BIT_SIZE)
					res[order * 2 - 1][x] = x & bit ? other : mine;
				else
					res[order * 2 - 1][x] = x & bit ? order * 2 + 2 : order * 2 + 1;
			}
			else
			{
				res[order * 2 - 1][x] = other;

				if (order == BIT_SIZE)
					res[order * 2][x] = x & bit ? other : mine;
				else
					res[order * 2][x] = x & bit ? order * 2 + 2 : order * 2 + 1;
			}
		}
	}

	return res;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...