Submission #1002811

# Submission time Handle Problem Language Result Execution time Memory
1002811 2024-06-19T19:55:36 Z Juan MalnaRISC (COI21_malnarisc) C++17
0 / 100
5 ms 604 KB
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>

void print(int a, int b){
	cout << "CMPSWP ";
	cout << "R" << a << " ";
	cout << "R" << b << " ";
}

int main(){
	int n; cin >> n;
	vector<pii> pares;
	for(int i=1; i<=n; i++){
		for(int j=i+1; j<=n; j++){
			pares.pb({i,j});
		}
	}


	int cnt=0;
	vector<vector<pii>> arr;
	while(pares.size()){
		shuffle(pares.begin(),pares.end(),default_random_engine(0));
		vector<bool> mark(n+1), mark_id((int)pares.size());
		arr.pb({});
		for(int i=0; i<pares.size(); i++){
			auto[a,b] = pares[i];
			if(!mark[a] && !mark[b]){
				mark[a]=mark[b]=true;
				arr.back().pb({a,b});
				mark_id[i]=true;
			}
		}

		vector<pii> aux;
		for(int i=0; i<pares.size(); i++){
			if(!mark_id[i]) aux.pb(pares[i]);
		}
		pares=aux;
		cnt++;
	}

	cout << cnt << '\n';
	for(auto v : arr){
		for(auto[a,b] : v) print(a,b);
		cout << '\n';
	}
}

Compilation message

malnarisc.cpp: In function 'int main()':
malnarisc.cpp:28:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |   for(int i=0; i<pares.size(); i++){
      |                ~^~~~~~~~~~~~~
malnarisc.cpp:38:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |   for(int i=0; i<pares.size(); i++){
      |                ~^~~~~~~~~~~~~
# 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 344 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 600 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 344 KB not sorted
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB not sorted
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 348 KB not sorted
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 604 KB not sorted
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 600 KB not sorted
2 Halted 0 ms 0 KB -