Submission #417346

# Submission time Handle Problem Language Result Execution time Memory
417346 2021-06-03T15:03:17 Z doowey MalnaRISC (COI21_malnarisc) C++14
60 / 100
1 ms 332 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main(){
    fastIO;
    int n;
    cin >> n;
    vector<vector<pii>> op;
    int li, ri;
    for(int lg = 1; lg < 7; lg ++ ){
        vector<pii> cc;
        for(int i = 0; i < n; i += (1 << lg) ){
            for(int j = 0 ; j < (1 << lg); j ++ ){
                ri = (1 << lg) - j - 1;
                if(j < ri){
                    if(i + j < n && i + ri < n){
                        cc.push_back(mp(i + j, i + ri));
                    }
                }
            }
        }
        if(!cc.empty())
            op.push_back(cc);
        for(int smol = lg - 2; smol >= 0 ; smol -- ){
            cc.clear();
            for(int i = 0 ; i < n; i += (1 << (smol + 1))){
                for(int j = 0 ; j < (1 << smol); j ++ ){
                    li = (i + j);
                    ri = (i + j + (1 << smol));
                    if(li < n && ri < n)
                        cc.push_back(mp(li, ri));
                }
            }
            if(!cc.empty())
                op.push_back(cc);
        }
        if((1 << lg) >= n) break;
    }
    cout << op.size() << "\n";
    for(auto x : op){
        for(auto y : x){
            cout << "CMPSWP " << "R" << y.fi + 1 << " " << "R" << y.se + 1 << " ";
        }
        cout << "\n";
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
# 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 312 KB not sorted
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB not sorted