Submission #575237

#TimeUsernameProblemLanguageResultExecution timeMemory
575237AJ00Permutation (APIO22_perm)C++17
0 / 100
1 ms212 KiB
#include <bits/stdc++.h> #include "perm.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--; } } 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:37:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     for (int i = 0; i < ans.size(); i++){
      |                     ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...