Submission #421346

# Submission time Handle Problem Language Result Execution time Memory
421346 2021-06-09T05:15:24 Z MetalPower MalnaRISC (COI21_malnarisc) C++14
0 / 100
1 ms 332 KB
#include <bits/stdc++.h>
using namespace std;

int N;
string s = "CMPSWP";

#define pii pair<int, int>
#define fi first
#define se second
#define mp make_pair

vector<pii> v;

bool vis[105];

void solve(){

	vector<vector<pii>> ans;
	ans.push_back({});

	for(auto& p : v){
		if(!vis[p.fi] && !vis[p.se]){
			vis[p.fi] = 1; vis[p.se] = 1;
		}else{
			memset(vis, 0, sizeof vis);
			ans.push_back({});
			vis[p.fi] = 1; vis[p.se] = 1;
		}
		ans.back().push_back(p);
	}

	cout << ans.size() << '\n';

	for(auto& a : ans){
		int n = a.size();
		for(int i = 0; i < n; i++){
			cout << s << " R" << a[i].fi << " R" << a[i].se << (i == n - 1 ? '\n' : ' ');
		}
	}
}

int LOG = 0;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);

	cin >> N;

	int curr = 1;

	while(curr < N){
		curr <<= 1; ++LOG;
	}

	for(int l = 1; l <= LOG; l++){
		for(int i = 1; i <= N; i += (1 << l)){
			for(int j = 0; j < (1 << l - 1); j++){
				int nxt = i + (1 << l) - j - 1;
				if(nxt <= N) v.push_back(mp(i, nxt));
			}
		}
		for(int _l = l - 1; _l > 0; _l--){
			for(int i = 1; i <= N; i += (1 << _l)){
				for(int j = 0; j < (1 << _l - 1); j++){
					int nxt = i + (1 << _l - 1) + j;
					if(nxt <= N) v.push_back(mp(i, nxt));
				}
			}
		}
	}

	solve();
}

Compilation message

malnarisc.cpp: In function 'int main()':
malnarisc.cpp:57:31: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   57 |    for(int j = 0; j < (1 << l - 1); j++){
      |                             ~~^~~
malnarisc.cpp:64:33: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   64 |     for(int j = 0; j < (1 << _l - 1); j++){
      |                              ~~~^~~
malnarisc.cpp:65:29: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   65 |      int nxt = i + (1 << _l - 1) + j;
      |                          ~~~^~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB not sorted
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB not sorted
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB not sorted
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB not sorted
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB not sorted
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 308 KB not sorted
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB not sorted
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB not sorted
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB not sorted
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB not sorted