Submission #982838

#TimeUsernameProblemLanguageResultExecution timeMemory
982838vjudge1Permutation (APIO22_perm)C++17
93.33 / 100
1 ms348 KiB
#include "perm.h" #include <bits/stdc++.h> #define rep(a,b,c) for(int a=b; a<c; a++) #define repr(a,b,c) for(int a=b-1; a>c-1; a--) #define repa(a,b) for(auto a:b) #define fi first #define se second #define pii pair<int, int> #define ll long long #define pb push_back using namespace std; string s; void solve(ll k){ if(k==1) return; if(k%3==0){ s+='0'; s+='2'; solve(k/3); }else if(k&1){ s+='1'; solve(k-1); }else{ s+='0'; solve(k/2); } } vector<int> construct_permutation(long long k){ vector<int> perm; s.clear(); solve(k); int x=0, y=s.size()-1; rep(i,0,s.size()){ if(s[i]=='1') perm.pb(x++); else perm.pb(y--); if(s[i]=='2') swap(perm[i],perm[i-1]); } ll z=1; reverse(perm.begin(),perm.end()); return perm; }

Compilation message (stderr)

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:3:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    3 | #define rep(a,b,c) for(int a=b; a<c; a++)
......
   36 |  rep(i,0,s.size()){
      |      ~~~~~~~~~~~~                 
perm.cpp:36:2: note: in expansion of macro 'rep'
   36 |  rep(i,0,s.size()){
      |  ^~~
perm.cpp:41:5: warning: unused variable 'z' [-Wunused-variable]
   41 |  ll z=1;
      |     ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...