Submission #915206

#TimeUsernameProblemLanguageResultExecution timeMemory
915206a_l_i_r_e_z_aPermutation (APIO22_perm)C++17
0 / 100
3 ms604 KiB
// In the name of God // Hope is last to die #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll, ll> pll; typedef pair<int, int> pii; #define pb push_back #define S second #define F first #define mp make_pair #define smax(x, y) (x) = max((x), (y)) #define smin(x, y) (x) = min((x), (y)) #define all(x) (x).begin(), (x).end() #define len(x) ((int)(x).size()) const int maxn = 200 + 5; const int inf = 1e9 + 7; vector<int> construct_permutation(ll k){ vector<int> vec; if(k == 1) return vec; if(k == 2){ vec.pb(0); return vec; } if(k == 3){ vec.pb(1); vec.pb(0); return vec; } ll r = k % 4; vec = construct_permutation(k / 4); int n = len(vec); if(r == 0){ vec.pb(n); vec.pb(n + 1); } else if(r == 1){ for(auto &u: vec) u++; vec.pb(n + 1); vec.pb(n + 2); vec.pb(0); } else if(r == 2){ for(auto &u: vec) u++; vec.pb(n + 1); vec.pb(0); vec.pb(n + 2); } else{ bool flag; for(auto u: vec) if(u < 2){ flag = u; break; } if(flag){ for(auto &u: vec) if(u > 1) u++; vec.pb(n + 1); vec.pb(n + 2); vec.pb(2); } else{ for(auto &u: vec) u += 2; vec.pb(n + 2); vec.pb(1); vec.pb(n + 3); vec.pb(0); } } } // int32_t main() // { // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // return 0; // }

Compilation message (stderr)

perm.cpp: In function 'std::vector<int> construct_permutation(ll)':
perm.cpp:75:1: warning: control reaches end of non-void function [-Wreturn-type]
   75 | }
      | ^
perm.cpp:61:9: warning: 'flag' may be used uninitialized in this function [-Wmaybe-uninitialized]
   61 |         if(flag){
      |         ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...