Submission #671081

# Submission time Handle Problem Language Result Execution time Memory
671081 2022-12-11T23:01:15 Z AdamGS Permutation (APIO22_perm) C++17
93.3333 / 100
2 ms 360 KB
#include "perm.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
vector<int>construct_permutation(ll k) {
        vector<int>ans;
        if(k==1) return ans;
        if(k%3==0) {
                ans=construct_permutation(k/3);
                rep(i, ans.size()) ans[i]+=2;
                reverse(all(ans));
                ans.pb(0);
                ans.pb(1);
                reverse(all(ans));
                return ans;
        }
        if(k%2==1) {
                ans=construct_permutation(k-1);
                reverse(all(ans));
                ans.pb(ans.size());
                reverse(all(ans));
                return ans;
        }
        ans=construct_permutation(k/2);
        rep(i, ans.size()) ++ans[i];
        reverse(all(ans));
        ans.pb(0);
        reverse(all(ans));
        return ans;
}

Compilation message

perm.cpp: In function 'std::vector<int> construct_permutation(ll)':
perm.cpp:6:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    6 | #define rep(a, b) for(int a = 0; a < (b); ++a)
      |                                    ^
perm.cpp:16:17: note: in expansion of macro 'rep'
   16 |                 rep(i, ans.size()) ans[i]+=2;
      |                 ^~~
perm.cpp:6:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    6 | #define rep(a, b) for(int a = 0; a < (b); ++a)
      |                                    ^
perm.cpp:31:9: note: in expansion of macro 'rep'
   31 |         rep(i, ans.size()) ++ans[i];
      |         ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Partially correct 1 ms 340 KB Partially correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 2 ms 360 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 304 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Partially correct 2 ms 340 KB Partially correct