Submission #1002745

# Submission time Handle Problem Language Result Execution time Memory
1002745 2024-06-19T19:15:42 Z pedroslrey MalnaRISC (COI21_malnarisc) C++17
76.8521 / 100
1 ms 348 KB
#include <bits/stdc++.h>

using namespace std;

vector<vector<pair<int, int>>> solve(int n) {
	if (n == 1) return {};

	int m = (n + 1)/2;
	vector<vector<pair<int, int>>> ans;
	for (int i = 0; i < m; ++i) {
		ans.emplace_back();
		for (int j = 0; j < n - m; ++j)
			ans.back().emplace_back((i + j)%m, j + m);
	}

	auto xs = solve(m), ys = solve(n - m);
	for (int i = 0; i < max(xs.size(), ys.size()); ++i) {
		ans.emplace_back();
		if (i < xs.size()) for (auto p: xs[i]) ans.back().push_back(p);
		if (i < ys.size()) for (auto [a, b]: ys[i]) ans.back().emplace_back(a + m, b + m);
	}

	return ans;
}

int main() {
	int n;
	cin >> n;

	auto ans = solve(n);

	cout << ans.size() << "\n";
	for (auto &xs: ans) {
		for (auto [a, b]: xs)
			cout << "CMPSWP R" << a + 1 << " R" << b + 1 << " ";
		cout << "\n";
	}
}

Compilation message

malnarisc.cpp: In function 'std::vector<std::vector<std::pair<int, int> > > solve(int)':
malnarisc.cpp:17:20: warning: comparison of integer expressions of different signedness: 'int' and 'const long unsigned int' [-Wsign-compare]
   17 |  for (int i = 0; i < max(xs.size(), ys.size()); ++i) {
      |                  ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
malnarisc.cpp:19:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |   if (i < xs.size()) for (auto p: xs[i]) ans.back().push_back(p);
      |       ~~^~~~~~~~~~~
malnarisc.cpp:20:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |   if (i < ys.size()) for (auto [a, b]: ys[i]) ans.back().emplace_back(a + m, b + m);
      |       ~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 348 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 344 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 344 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 348 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 348 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 348 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 348 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 348 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 348 KB Partially correct