Submission #512605

# Submission time Handle Problem Language Result Execution time Memory
512605 2022-01-16T13:39:42 Z David_M MalnaRISC (COI21_malnarisc) C++14
0 / 100
1 ms 336 KB
#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define FF first.first
#define FS first.second
#define pb push_back
using namespace std;
ll n, T;
vector <pii> v[50];

void add(int x, int y, int t){
    x++; y++;
    if(x>n || y>n)x=y=1;
    v[t].pb({x, y});T=t;
}

int merge(int l, int r, int t){
    int m=l+r>>1, e=r-l>>1;
    for (int i=l; i<m; i++)add(i, i+e, t);
    return (l+1==r) ? t : merge(l+m>>1, m+r>>1, t+1);
}

void solve(int l, int r, int t=1){
    if(l+1==r)return;
    //cout<<t<<" ";
    t=merge(l, r, t);
    //cout<<t<<endl;
    solve(l, l+r>>1, t);
    solve(l+r>>1, r, t);
}

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(){ios_base::sync_with_stdio(false), cin.tie(0);

	cin>>n;
	int k=1;
	while(k<n)k<<=1;
	solve(0, k);
    output();
}

Compilation message

malnarisc.cpp: In function 'int merge(int, int, int)':
malnarisc.cpp:21:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   21 |     int m=l+r>>1, e=r-l>>1;
      |           ~^~
malnarisc.cpp:21:22: warning: suggest parentheses around '-' inside '>>' [-Wparentheses]
   21 |     int m=l+r>>1, e=r-l>>1;
      |                     ~^~
malnarisc.cpp:23:34: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   23 |     return (l+1==r) ? t : merge(l+m>>1, m+r>>1, t+1);
      |                                 ~^~
malnarisc.cpp:23:42: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   23 |     return (l+1==r) ? t : merge(l+m>>1, m+r>>1, t+1);
      |                                         ~^~
malnarisc.cpp: In function 'void solve(int, int, int)':
malnarisc.cpp:31:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   31 |     solve(l, l+r>>1, t);
      |              ~^~
malnarisc.cpp:32:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   32 |     solve(l+r>>1, r, t);
      |           ~^~
malnarisc.cpp: In function 'void output()':
malnarisc.cpp:38:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   38 |         for(auto [x,y]:v[i])cout<<"CMPSWP R"<<x<<" R"<<y<<" ";
      |                  ^
malnarisc.cpp: At global scope:
malnarisc.cpp:43:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   43 | main(){ios_base::sync_with_stdio(false), cin.tie(0);
      | ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 292 KB not sorted
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 316 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB not sorted
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB not sorted
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB not sorted
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 296 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 316 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct