답안 #420613

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
420613 2021-06-08T12:57:54 Z Berted MalnaRISC (COI21_malnarisc) C++14
65.8026 / 100
2 ms 332 KB
#include <iostream>
#include <vector>
#define vi vector<int>
#define pii pair<int, int>
#define fst first
#define snd second
#define vpi vector<pii>


using namespace std;

int N;
vector<vpi> ans;

int solve(int L, int R)
{
	if (L < R)
	{
		int M = L + R >> 1, idx = 0;
		idx = max(idx, solve(L, M));
		idx = max(idx, solve(M + 1, R));

		int sz = R - M;
		for (int j = 0; j < sz; j++)
		{
			while (ans.size() <= idx) ans.push_back(vpi());
			for (int k = 0; k < sz; k++)
			{
				ans[idx].push_back({k + L, (k + j) % sz + M + 1});
			}
			idx++;
		}

		if (M - L + 1 > R - M)
		{
			while (ans.size() <= idx) ans.push_back(vpi());
			for (int k = 0; k < sz; k++)
			{
				ans[idx].push_back({M, k + M + 1});
			}
			idx++;
		}
		return idx;
	}
	return 0;
}

int main()
{
	cin >> N;
	for (int i = 0; i < N + 4; i++)
	{
		ans.push_back(vpi());
		for (int j = i % 2 + 1; j + 1 <= N; j += 2)
		{
			ans.back().push_back({j, j + 1});
		}
	}

	cout << ans.size() << "\n";
	for (auto &V : ans)
	{
		for (int i = 0; i < V.size(); i++)
		{
			if (V[i].fst > V[i].snd) swap(V[i].fst, V[i].snd);
			cout << "CMPSWP R" << V[i].fst << " R" << V[i].snd << " \n"[i + 1 == V.size()];
		}
	}
	return 0;
}

Compilation message

malnarisc.cpp: In function 'int solve(int, int)':
malnarisc.cpp:19:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   19 |   int M = L + R >> 1, idx = 0;
      |           ~~^~~
malnarisc.cpp:26:22: warning: comparison of integer expressions of different signedness: 'std::vector<std::vector<std::pair<int, int> > >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   26 |    while (ans.size() <= idx) ans.push_back(vpi());
      |           ~~~~~~~~~~~^~~~~~
malnarisc.cpp:36:22: warning: comparison of integer expressions of different signedness: 'std::vector<std::vector<std::pair<int, int> > >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |    while (ans.size() <= idx) ans.push_back(vpi());
      |           ~~~~~~~~~~~^~~~~~
malnarisc.cpp: In function 'int main()':
malnarisc.cpp:63:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |   for (int i = 0; i < V.size(); i++)
      |                   ~~^~~~~~~~~~
malnarisc.cpp:66:70: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |    cout << "CMPSWP R" << V[i].fst << " R" << V[i].snd << " \n"[i + 1 == V.size()];
      |                                                                ~~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Partially correct 1 ms 204 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 1 ms 204 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 1 ms 204 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 1 ms 204 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 1 ms 332 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 1 ms 332 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 1 ms 332 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 1 ms 332 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 2 ms 332 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 2 ms 332 KB Partially correct