Submission #420667

# Submission time Handle Problem Language Result Execution time Memory
420667 2021-06-08T13:14:08 Z maximath_1 MalnaRISC (COI21_malnarisc) C++17
100 / 100
1 ms 332 KB
#include <iostream>
#include <unordered_map>
#include <algorithm>
#include <set>
#include <string>
#include <vector>
#include <random>
#include <deque>
using namespace std;

mt19937 rng(420691273);
#define ll long long
const int MX = 1e5 + 5;

// query = ceil(log) * (ceil(log) + 1) / 2

int main(){
	cin.tie(0) -> sync_with_stdio(0);

	int n; cin >> n;
	vector<vector<pair<int, int> > > ans;
	int lg;
	for(lg = 0; (1 << lg) < n; lg ++);

	for(int len = 1; len <= lg; len ++){
		vector<pair<int, int> > nw;
		for(int i = 0; i < n; i += (1 << len))
			for(int j = 0; j < (1 << (len - 1)); j ++)
				if(i + (1 << len) - j - 1 < n)
					nw.push_back({i + j, i + (1 << len) - j - 1});
		if(nw.size()) ans.push_back(nw);
		for(int len2 = len - 1; len2 > 0; len2 --){
			nw.clear();
			for(int i = 0; i < n; i += (1 << len2))
				for(int j = 0; j < (1 << (len2 - 1)); j ++)
					if(i + j + (1 << (len2 - 1)) < n)
						nw.push_back({i + j, i + j + (1 << (len2 - 1))});
			ans.push_back(nw);
		}
	}

	cout << ans.size() << endl;
	for(auto i : ans){
		for(auto j : i)
			cout << "CMPSWP R" << j.first + 1 << " R" << j.second + 1 << " ";
		cout << endl;
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct