Submission #404784

# Submission time Handle Problem Language Result Execution time Memory
404784 2021-05-15T02:02:19 Z tqbfjotld MalnaRISC (COI21_malnarisc) C++14
80 / 100
2 ms 332 KB
#include <bits/stdc++.h>
using namespace std;

vector<vector<pair<int,int> > > stuff(int n){
    if (n==2){
        vector<pair<int,int> > t;
        t.push_back({1,2});
        vector<vector<pair<int,int> > >ret;
        ret.push_back(t);
        return ret;
    }
    vector<vector<pair<int,int> > > ret;
    auto res = stuff(n/2);
    for (auto x : res){
        vector<pair<int,int> > t;
        for (auto y : x){
            t.push_back({n/2+1-y.first,n/2+1-y.second});
            t.push_back({n/2+y.first,n/2+y.second});
        }
        ret.push_back(t);
    }
    int t2 = n/2;
    while (t2>0){
        vector<pair<int,int> > t;
        for (int x = 0; x<n; x++){
            if ((x&t2)==0){
                t.push_back({x+1,x+t2+1});
            }
        }
        ret.push_back(t);
        t2>>=1;
    }
    return ret;
}


int main(){
    int n;
    scanf("%d",&n);
    int t = 1;
    while (t<n) t<<=1;
    auto res = stuff(t);
    printf("%d\n",res.size());
    for (auto x : res){
        for (auto y : x){
            if (y.first>n || y.second>n) continue;
            printf("CMPSWP R%d R%d ",y.first,y.second);
        }
        printf("\n");
    }
}

Compilation message

malnarisc.cpp: In function 'int main()':
malnarisc.cpp:43:14: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<std::vector<std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wformat=]
   43 |     printf("%d\n",res.size());
      |             ~^    ~~~~~~~~~~
      |              |            |
      |              int          std::vector<std::vector<std::pair<int, int> > >::size_type {aka long unsigned int}
      |             %ld
malnarisc.cpp:39:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
# 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 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 2 ms 332 KB not sorted
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct