Submission #421347

#TimeUsernameProblemLanguageResultExecution timeMemory
421347MetalPowerMalnaRISC (COI21_malnarisc)C++14
100 / 100
1 ms332 KiB
#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((1 << LOG) < N) ++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 + j, 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 + j, nxt)); } } } } solve(); }

Compilation message (stderr)

malnarisc.cpp: In function 'int main()':
malnarisc.cpp:55:31: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   55 |    for(int j = 0; j < (1 << l - 1); j++){
      |                             ~~^~~
malnarisc.cpp:62:33: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   62 |     for(int j = 0; j < (1 << _l - 1); j++){
      |                              ~~~^~~
malnarisc.cpp:63:29: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   63 |      int nxt = i + (1 << _l - 1) + j;
      |                          ~~~^~~
malnarisc.cpp:49:6: warning: unused variable 'curr' [-Wunused-variable]
   49 |  int curr = 1;
      |      ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...