Submission #1002804

# Submission time Handle Problem Language Result Execution time Memory
1002804 2024-06-19T19:50:04 Z PagodePaiva MalnaRISC (COI21_malnarisc) C++17
10.7073 / 100
1 ms 348 KB
#include<bits/stdc++.h>
#define endl '\n'

using namespace std;

int main(){
	int n;
	cin >> n;
	int l = 1, r = n;
	int cnt = 0;
	vector <vector <pair <int, int>>> res;
	for(int i = n;i > 1;i--){
		vector <int> big;
		for(int j = 1;j <= i;j++) big.push_back(j);
		while(big.size() > 1){
			vector <int> aux;
			vector <pair <int, int>> resp;
			for(int t = 0;t+1 < big.size();t += 2){
				resp.push_back({big[t], big[t+1]});
				aux.push_back(big[t+1]);
			}
			res.push_back(resp);
			cnt++;
			if(big.size() % 2 == 1) aux.push_back(big.back());
			big = aux;
		}
	}
	cout << cnt << endl;
		for(auto y : res){
			for(auto x : y){
				cout << "CMPSWP R" << x.first << " R" << x.second << ' ';
			}
			cout << endl;
		}
	return 0;
}

Compilation message

malnarisc.cpp: In function 'int main()':
malnarisc.cpp:18:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |    for(int t = 0;t+1 < big.size();t += 2){
      |                  ~~~~^~~~~~~~~~~~
malnarisc.cpp:9:6: warning: unused variable 'l' [-Wunused-variable]
    9 |  int l = 1, r = n;
      |      ^
malnarisc.cpp:9:13: warning: unused variable 'r' [-Wunused-variable]
    9 |  int l = 1, r = n;
      |             ^
# 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 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 0 ms 348 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 1 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 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 344 KB Partially correct