Submission #1002919

# Submission time Handle Problem Language Result Execution time Memory
1002919 2024-06-19T21:21:28 Z PagodePaiva MalnaRISC (COI21_malnarisc) C++17
0 / 100
1 ms 348 KB
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;

const int debug = 0;

int32_t main(){
	int n;
	cin >> n;
	vector <pair <int, int>> mergear;
	for(int i = 1;i <= n;i++){
		mergear.push_back({i, i});
	}
	vector <vector <pair <int, int>>> res;
	while(mergear.size() > 1){
		vector <pair <int, int>> aux[100];
		vector <pair <int, int>> novo;
		for(int i = 0;i+1 < mergear.size();i += 2){
			auto [l1, r1] = mergear[i];
			auto [l2, r2] = mergear[i+1];
			novo.push_back({l1, r2});
			int con = 0;
			while(r1-l1+1 > 1 and r2-l2+1 > 1){
				aux[con].push_back({l1, l2});
				aux[con].push_back({r1, r2});
				l1++;
				r2--;
				con++;
			}
			if(l1 == r1){
				for(int i = l2;i <= r2;i++){
					aux[con].push_back({l1, i});
					con++;
				}
			}
			else{
				for(int i = r1;i >= l1;i--){
					aux[con].push_back({r2, i});
					con++;
				}
			}
		}
		for(int i = 0;i < 100;i++){
			if(!aux[i].empty()) res.push_back(aux[i]);
		}
		if(mergear.size() % 2) novo.push_back(mergear.back());
		mergear = novo;
	}
	cout << res.size() << endl;
	for(auto vec : res){
		for(auto x : vec){
			cout << "CMPSWP R" << min(x.first, x.second) << " R" << max(x.first, x.second) << ' ';
		}
		cout << endl;
	}
	return 0;
}

Compilation message

malnarisc.cpp: In function 'int32_t main()':
malnarisc.cpp:18: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]
   18 |   for(int i = 0;i+1 < mergear.size();i += 2){
      |                 ~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB not sorted
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB not sorted
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB not sorted
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB not sorted
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB not sorted
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB not sorted
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB not sorted
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB not sorted
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB not sorted
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB not sorted
2 Halted 0 ms 0 KB -