Submission #660073

# Submission time Handle Problem Language Result Execution time Memory
660073 2022-11-20T10:08:37 Z ymm The Collection Game (BOI21_swaps) C++17
0 / 100
53 ms 208 KB
#include "swaps.h"
#include <bits/stdc++.h>
#define Loop(x,l,r) for (ll x = (l); x < (ll)(r); ++x)
#define LoopR(x,l,r) for (ll x = (r)-1; x >= (ll)(l); --x)
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll , ll > pll;
using namespace std;

const int LG = 9;
const int N = 1<<LG;
vector<int> ord;
vector<pii> sched;
int n;

vector<int> cmp()
{
	int cnt = 0;
	for (auto [i, j] : sched) {
		int x = ord[i];
		int y = ord[j];
		if (x > n || y > n)
			continue;
		schedule(x, y);
		++cnt;
	}
	vector<int> res = cnt? visit(): vector<int>(), ans;
	reverse(res.begin(), res.end());
	for (auto [i, j] : sched) {
		int x = ord[i];
		int y = ord[j];
		if (x > n || y > n) {
			ans.push_back(x < y);
		} else {
			ans.push_back(res.back());
			res.pop_back();
		}
	}
	sched.clear();
	return ans;
}

void Do(int cnt)
{
	for (int sz = N/2; cnt--; sz /= 2) {
		Loop (i,0,N/2)
			sched.push_back({2*i, 2*i+1});
		auto res = cmp();
		vector<int> vec;
		for (int l = 0; l < N/2; l += sz) {
			int r = l + sz;
			Loop (i,l,r)
				vec.push_back(ord[2*i + !res[i]]);
			Loop (i,l,r)
				vec.push_back(ord[2*i + res[i]]);
		}
		ord = vec;
	}
}

void solve(int _n, int v)
{
	n = _n;
	ord.resize(N);
	iota(ord.begin(), ord.end(), 1);
	Loop (_,0,v/LG)
		Do(LG);
	if (ord[N-2] != N-1) {
		Loop (i,0,N) {
			int j = 0;
			Loop (k,0,LG) {
				j <<= 1;
				j ^= (i>>k)&1;
			}
			if (i < j)
				swap(ord[i], ord[j]);
		}
	}
	ord.resize(n);
	answer(ord);
}
# Verdict Execution time Memory Grader output
1 Incorrect 46 ms 208 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 49 ms 208 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 51 ms 208 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 51 ms 208 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 50 ms 208 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 50 ms 208 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 53 ms 208 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 53 ms 208 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 45 ms 208 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 45 ms 208 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 44 ms 208 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 44 ms 208 KB Not correct
2 Halted 0 ms 0 KB -