Submission #597555

#TimeUsernameProblemLanguageResultExecution timeMemory
597555boris_mihovArt Collections (BOI22_art)C++17
100 / 100
1842 ms640 KiB
#include "art.h" #include <numeric> #include <iostream> std::vector < int > perm, ans; void solve(int n) { perm.resize(n); ans.reserve(n); std::iota(perm.begin(), perm.end(), 1); int lastInv = publish(perm), currInv; ans.push_back(n); for (int i = n-2 ; i >= 0 ; --i) { perm.erase(perm.begin() + i); perm.push_back(i + 1); currInv = publish(perm); int bigger = (currInv - lastInv + (n - i - 1)) / 2; ans.insert(ans.end() - bigger, i + 1); lastInv = currInv; } answer(ans); }

Compilation message (stderr)

interface.cpp: In function 'int publish(std::vector<int>)':
interface.cpp:20:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |     if(v.size() != N) {
      |        ~~~~~~~~~^~~~
interface.cpp: In function 'void answer(std::vector<int>)':
interface.cpp:36:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |     if(v.size() != N) {
      |        ~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...