Submission #1002729

# Submission time Handle Problem Language Result Execution time Memory
1002729 2024-06-19T18:41:12 Z Lobo MalnaRISC (COI21_malnarisc) C++17
0 / 100
1 ms 356 KB
#include<bits/stdc++.h>
using namespace std;
#define pb push_back

int main() {
	// #ifndef ONLINE_JUDGE
	// freopen("in.in","r",stdin);
	// freopen("out.out","w",stdout);
	// #endif

	int n; cin >> n;
	vector<string> lines;
	// for(int it = 0; it < n-it; it++) {
	// 	vector<vector<int>> ids;
	// 	ids.pb({});
	// 	for(int x = it; x < n-it; x++) ids.back().pb(x);

	// 	for(int i = 0; i < 7; i++) {
	// 		lines.pb("");
	// 		vector<vector<int>> newids;
	// 		for(auto idss : ids) {
	// 			if(idss.size() == 1) continue;
	// 			int s1 = idss.size()/2;
	// 			int s2 = (int) idss.size()-s1;
	// 			if(s1 != 1 && s1%2 == 1) {
	// 				s1++;
	// 				s2--;
	// 			}
	// 			for(int j = 0; j+idss.size()/2 < idss.size(); j++) {
	// 				int y = idss[j];
	// 				int x = idss[j+idss.size()/2];
	// 				lines.back() += ("CMPSWP R"+to_string(y+1)+" R"+to_string(x+1)+" ");
	// 			}

	// 		}
			
	// 		// for(int x = it; x < n-it; x++) {
	// 		// 	int y = (x^(1<<i));
	// 		// 	if(y > x) continue;
	// 		// 	lines.back() += ("CMPSWP R"+to_string(y+1)+" R"+to_string(x+1)+" ");
	// 		// }
	// 		if(lines.back().size() == 0) lines.pop_back();
	// 		else lines.back().pop_back();
	// 	}
	// }

	vector<vector<int>> vecs;
	vecs.pb({});
	for(int i = 0; i < n; i++) vecs.back().pb(i);
	for(int b = 6; b >= 0; b--) {
		lines.pb("");
		vector<vector<int>> newvecs;
		for(auto vec : vecs) {
			if(vec.size() == 1) continue;
			for(int i = 0; i < vec.size()/2; i++) {
				lines.back() += ("CMPSWP R"+to_string(vec[i]+1)+" R"+to_string(vec[i+vec.size()/2]+1)+" ");
			}
			newvecs.pb({});
			for(int i = 0; i < vec.size()/2; i++) newvecs.back().pb(vec[i]);
			if(newvecs.back().size() == 0) newvecs.pop_back();
			newvecs.pb({});
			for(int i = vec.size()/2; i < vec.size(); i++) newvecs.back().pb(vec[i]);
			if(newvecs.back().size() == 0) newvecs.pop_back();
		}

		vecs = newvecs;
		if(lines.back().size() == 0) lines.pop_back();
		else lines.back().pop_back();
	}

	vector<string> ans = lines;
	// for(int s = 0; s < n; s++) {
	// 	for(int i = s-s; i < s-s+lines.size(); i++) {
	// 		ans.pb(lines[i%(int) lines.size()]);
	// 	}
	// }

	cout << ans.size() << endl;
	for(auto x : ans) {
		cout << x << endl;
	}
}

Compilation message

malnarisc.cpp: In function 'int main()':
malnarisc.cpp:55:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |    for(int i = 0; i < vec.size()/2; i++) {
      |                   ~~^~~~~~~~~~~~~~
malnarisc.cpp:59:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |    for(int i = 0; i < vec.size()/2; i++) newvecs.back().pb(vec[i]);
      |                   ~~^~~~~~~~~~~~~~
malnarisc.cpp:62:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |    for(int i = vec.size()/2; i < vec.size(); i++) newvecs.back().pb(vec[i]);
      |                              ~~^~~~~~~~~~~~
# 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 0 ms 356 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 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 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 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 -