Submission #421344

# Submission time Handle Problem Language Result Execution time Memory
421344 2021-06-09T05:13:10 Z MetalPower MalnaRISC (COI21_malnarisc) C++14
Compilation error
0 ms 0 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 : v){
		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' : ' ');
		}
	}
}

const int LOG = 7;

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

	cin >> N;

	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 'void solve()':
malnarisc.cpp:35:13: error: 'struct std::pair<int, int>' has no member named 'size'
   35 |   int n = a.size();
      |             ^~~~
malnarisc.cpp:37:26: error: no match for 'operator[]' (operand types are 'std::pair<int, int>' and 'int')
   37 |    cout << s << " R" << a[i].fi << " R" << a[i].se << (i == n - 1 ? '\n' : ' ');
      |                          ^
malnarisc.cpp:37:45: error: no match for 'operator[]' (operand types are 'std::pair<int, int>' and 'int')
   37 |    cout << s << " R" << a[i].fi << " R" << a[i].se << (i == n - 1 ? '\n' : ' ');
      |                                             ^
malnarisc.cpp: In function 'int main()':
malnarisc.cpp:51:31: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   51 |    for(int j = 0; j < (1 << l - 1); j++){
      |                             ~~^~~
malnarisc.cpp:58:33: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   58 |     for(int j = 0; j < (1 << _l - 1); j++){
      |                              ~~~^~~
malnarisc.cpp:59:29: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   59 |      int nxt = i + (1 << _l - 1) + j;
      |                          ~~~^~~