Submission #975655

#TimeUsernameProblemLanguageResultExecution timeMemory
975655ShaShiPermutation (APIO22_perm)C++17
91.33 / 100
2 ms596 KiB
#include "perm.h" #include <bits/stdc++.h> #define F first #define S second #define all(x) x.begin(), x.end() #define pb push_back #define mp make_pair #define pii pair<int, int> using namespace std; typedef long long ll; const int MAXN = (int)1e6 + 7; const int LG = 60; vector<int> construct_permutation(ll k) { vector<int> res; bool flag = 0; for (int i=LG-1; i>=0; i--) { if (!(k&(1ll<<i))) continue; // for (int j:res) cout << j << " "; // cout << endl; // cout << "!" << i << endl; if (!flag) { for (int j=1; j<=i; j++) res.pb(j); flag = 1; continue; } for (int j=0; j<res.size(); j++) if (res[j] >= i+1) res[j]++; res.pb(i+1); } for (int i=0; i<res.size(); i++) res[i]--; return res; } // int main() { // vector<int> res = construct_permutation(42); // for (int i:res) cout << i << " "; // return 0; // }

Compilation message (stderr)

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