Submission #706822

#TimeUsernameProblemLanguageResultExecution timeMemory
706822grossly_overconfidentPermutation (APIO22_perm)C++17
0 / 100
0 ms212 KiB
#include "perm.h" #include <bits/stdc++.h> using namespace std; vector<int> construct_permutation(long long k) { int i = 1; set<long long> p; while (pow(2, i) < LONG_LONG_MAX){ p.insert(pow(2, i)); i++; } long long remaining = k - (k % 2); vector<int> out, found; if (k % 2 != 0){ out.push_back(INT_MAX); } while (remaining > 0){ long long t = *(--p.upper_bound(remaining)); remaining -= t; found.push_back(t); } for (int i = 0; i < log2(found[0]); ++i){ out.push_back(i); } for (int i = 1; i < found.size(); ++i){ out.push_back(log2(found[i]) - 1); } return out; } int no(){ int n; cin >> n; auto g = construct_permutation(n); for (auto h : g){ cout << h << endl; } }

Compilation message (stderr)

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:29:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |  for (int i = 1; i < found.size(); ++i){
      |                  ~~^~~~~~~~~~~~~~
perm.cpp: In function 'int no()':
perm.cpp:42:1: warning: no return statement in function returning non-void [-Wreturn-type]
   42 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...