Submission #420848

# Submission time Handle Problem Language Result Execution time Memory
420848 2021-06-08T14:21:57 Z Drew_ MalnaRISC (COI21_malnarisc) C++17
0 / 100
1 ms 332 KB
#include <iostream>
#include <vector>
#include <bitset>
using namespace std;

#define pb push_back
#define ii pair<int, int>
#define f1 first
#define s2 second

bitset<169> used;
int main()
{
	ios :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;
	
	vector<ii> rem;
	const auto rc = [&](const auto &self, int l, int r)
	{
		if (l >= r)
			return;

		int mid = (l + r) >> 1;
		for (int i = l; i < mid; ++i)
			rem.pb({i, mid});
		for (int i = mid+1; i <= r; ++i)
			rem.pb({mid, i});
		self(self, l, mid-1);
		self(self, mid+1, r);
	};
	rc(rc, 1, n);
	// for (int i = 1; i <= n; ++i)
	// 	for (int j = i+1; j <= n; ++j)
	// 		rem.pb({i, j});

	vector<vector<ii>> res;
	while (!rem.empty())
	{
		used.reset();
		vector<ii> out, nxt;
		for (auto [a, b] : rem)
		{
			if (!used[a] && !used[b])
				out.pb({a, b}), used[a] = used[b] = true;
			else nxt.pb({a, b});
		}

		res.pb(out);
		rem = nxt;
	}
	
	cout << res.size() << '\n';
	for (auto &out : res)
	{
		for (int i = 0; i < (int)out.size(); ++i)
			cout << "CMPSWP R" << out[i].f1 << " R" << out[i].s2 << " \n"[i+1 == (int)out.size()];
	}

	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB not sorted
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB not sorted
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB not sorted
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 236 KB not sorted
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB not sorted
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB not sorted
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB not sorted
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB not sorted
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB not sorted
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB not sorted