Submission #599862

#TimeUsernameProblemLanguageResultExecution timeMemory
599862isaachewArt Collections (BOI22_art)C++17
100 / 100
1560 ms676 KiB
#include "art.h" /* Guess permutation from number of inverted (unordered) pairs Maximum can be found Find the minimum element by placing them at the start, then querying n(n+1)/2 queries; satisfies ST2 Swap a block to know how many in one are less than the other O(n log n) sort? Score of x 1 2 ... N-2 N-1 N = score of original - sum(a_i>a_x) + sum(a_i<a_x) sum(a_i>a_x) + sum(a_i<a_x) = x (quicksort-like comparison) (newscore-curscore+x)/2 Already sorted a region; query 2n-2 solution; This gives 70? points Next score can be computed as score of original - sum(a_i>a_x) This has a count of N */ void solve(int N) { std::vector<int> cperm; cperm.push_back(1); std::vector<int> curq; for(int i=0;i<N;i++){ curq.push_back(i+1); } int ns=publish(curq); for(int i=1;i<N;i++){ curq.clear(); curq.push_back(i+1); curq.insert(curq.end(),cperm.begin(),cperm.end()); for(int j=i+1;j<N;j++){ curq.push_back(j+1); } int q2=publish(curq); int place=(q2-ns+i)/2; ns-=(i-place); cperm.insert(cperm.begin()+place,i+1); } answer(cperm); }

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...