Submission #575240

#TimeUsernameProblemLanguageResultExecution timeMemory
575240AJ00Permutation (APIO22_perm)C++17
91.33 / 100
2 ms340 KiB
#include <bits/stdc++.h> using namespace std; int n; const int MOD = 1000000007; vector<int> construct_permutation(long long int k){ vector<int> ans,op; ans.push_back(0); if (k == 2){ return ans; } // cerr << dp[k] << "\n"; long long int cur = k; while (cur != 2){ if (cur%2==0){ op.push_back(2); cur = (cur/2); } else { op.push_back(1); cur--; } } reverse(op.begin(),op.end()); int maxm = 0,minm=0; for (int e: op){ if (e == 2){ ++maxm; ans.push_back(maxm); } else { --minm; ans.push_back(minm); } } for (int i = 0; i < ans.size(); i++){ ans[i] += abs(minm); } return ans; }

Compilation message (stderr)

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