Submission #512656

#TimeUsernameProblemLanguageResultExecution timeMemory
512656David_MMalnaRISC (COI21_malnarisc)C++14
100 / 100
1 ms204 KiB
#include <bits/stdc++.h> #define pb push_back using namespace std; int n, T=1; vector <pair<int,int> > v[30]; void add(int x, int y, int t){ x++; y++; if(x>n || y>n)return; v[t].pb({x, y});T=t; } int merge(int l, int r, int t){ int m=l+r>>1, e=r-l>>1; while(e){ for (int i=l; i<r; i++)if((i/e-m/e)&1 && i+e<r)add(i, i+e, t); e>>=1; t++; } return t; } int solve(int l, int r, int t=1){ if(l+1==r)return t; int tt; tt=solve(l, l+r>>1, t); tt=solve(l+r>>1, r, t); tt=merge(l, r, tt); return tt; } void output(){ cout<<T<<'\n'; for (int i=1; i<=T; i++){ for(auto [x,y]:v[i])cout<<"CMPSWP R"<<x<<" R"<<y<<" "; cout<<'\n'; } } main(){ cin>>n; int k=1; while(k<n)k<<=1; solve(0, k); output(); }

Compilation message (stderr)

malnarisc.cpp: In function 'int merge(int, int, int)':
malnarisc.cpp:13:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   13 |     int m=l+r>>1, e=r-l>>1;
      |           ~^~
malnarisc.cpp:13:22: warning: suggest parentheses around '-' inside '>>' [-Wparentheses]
   13 |     int m=l+r>>1, e=r-l>>1;
      |                     ~^~
malnarisc.cpp: In function 'int solve(int, int, int)':
malnarisc.cpp:25:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   25 |     tt=solve(l, l+r>>1, t);
      |                 ~^~
malnarisc.cpp:26:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   26 |     tt=solve(l+r>>1, r, t);
      |              ~^~
malnarisc.cpp: In function 'void output()':
malnarisc.cpp:34:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   34 |         for(auto [x,y]:v[i])cout<<"CMPSWP R"<<x<<" R"<<y<<" ";
      |                  ^
malnarisc.cpp: At global scope:
malnarisc.cpp:39:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   39 | main(){
      | ^~~~
#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...