Submission #630183

#TimeUsernameProblemLanguageResultExecution timeMemory
630183Ooops_sorryPermutation (APIO22_perm)C++17
100 / 100
2 ms384 KiB
#include<bits/stdc++.h> using namespace std; mt19937 rnd(51); #define ll long long #define pb push_back #define ld long double vector<int> construct_permutation(long long k) { if (k == 1) { return {}; } if (k == 2) { return {0}; } for (auto d : {2, 3, 5, 7, 11, 13, 17}) { if (k % d == 0 && k > d) { vector<int> a = construct_permutation(k / d), b = construct_permutation(d); for (int i = 0; i < b.size(); i++) { b[i] += a.size(); } for (int i = 0; i < b.size(); i++) { a.pb(b[i]); } return a; } } vector<int> a = construct_permutation(k / 2); a.pb(a.size()); if (k & 1) { vector<int> res{a.size()}; for (auto to : a) { res.pb(to); } swap(a, res); } return a; }

Compilation message (stderr)

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:22:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |             for (int i = 0; i < b.size(); i++) {
      |                             ~~^~~~~~~~~~
perm.cpp:25:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |             for (int i = 0; i < b.size(); i++) {
      |                             ~~^~~~~~~~~~
perm.cpp:34:31: warning: narrowing conversion of 'a.std::vector<int>::size()' from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' [-Wnarrowing]
   34 |         vector<int> res{a.size()};
      |                         ~~~~~~^~
perm.cpp:34:31: warning: narrowing conversion of 'a.std::vector<int>::size()' from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' [-Wnarrowing]
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...