Submission #1003717

# Submission time Handle Problem Language Result Execution time Memory
1003717 2024-06-20T16:12:49 Z leanchec MalnaRISC (COI21_malnarisc) C++17
0 / 100
1 ms 348 KB
#include<bits/stdc++.h>
using namespace std;

string a="CMPSWP ";

vector<string> resp;
string cl="";

bool usou[110]={};

void compare(int n1, int b){
	if(usou[n1] || usou[b]){
		resp.push_back(cl);
		cl="";
		for(int i=1; i<=100; i++)
			usou[i]=false;
	}
	string aux=a;
	aux+="R";
	aux+=to_string(n1);
	aux+=" R";
	aux+=to_string(b);
	aux+=" ";
	usou[n1]=true;
	usou[b]=true;
	cl+=aux;
}

void bitonicMerge(int lo, int n){
	if(n>1){
		int m=1;
		while(n>=(1<<(m+1)))
			m<<=1;
		for(int i=lo; i<lo+n-m; i++)
			compare(i, i+m);
		bitonicMerge(lo, m);
		bitonicMerge(lo+m, n-m);
	}
}

void bitonicsort(int lo, int n){
	if(n>1){
		int m=n/2;
		bitonicsort(lo, m);
		bitonicsort(lo+m, n-m);
		bitonicMerge(lo, n);
	}
}

int main(){
	int n;
	cin >> n;
	bitonicsort(1, n);
	cout << resp.size() << endl;
	for(auto x:resp)
		cout << x << endl;
}
# 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 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 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 1 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 1 ms 344 KB not sorted
2 Halted 0 ms 0 KB -