Submission #638525

#TimeUsernameProblemLanguageResultExecution timeMemory
638525Tuanlinh123Permutation (APIO22_perm)C++17
88.60 / 100
3 ms340 KiB
#include<bits/stdc++.h> #define ll long long #define ld long double #define pll pair<ll,ll> #define mp make_pair #define pb push_back #define fi first #define se second using namespace std; #define LOCALIO "C:/Users/admin/Documents/Code/freopen/" vector <int> construct_permutation (ll k) { vector <ll> action; while (k>1) { bool added=0; for (ll i=2; i<=23; i++) if (k%i==0) { added=1; action.pb(i); k/=i; break; } if (!added) { k--; action.pb(1); } } reverse(action.begin(), action.end()); deque <int> q; ll num=0; for (ll i=0; i<action.size(); i++) { if (action[i]==1) { q.push_back(num); num++; } else { for (ll j=num+action[i]-2; j>=num; j--) q.push_front(j); num+=action[i]-1; } } // cout << "bruh" << flush; vector <int> res; while (!q.empty()) { res.pb(q.back()); q.pop_back(); } return res; }

Compilation message (stderr)

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:36:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for (ll i=0; i<action.size(); i++)
      |                  ~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...