Submission #599860

#TimeUsernameProblemLanguageResultExecution timeMemory
599860isaachewArt Collections (BOI22_art)C++17
70 / 100
1642 ms644 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 */ void solve(int N) { std::vector<int> cperm; cperm.push_back(1); for(int i=1;i<N;i++){ std::vector<int> curq(cperm); for(int j=i;j<N;j++){ curq.push_back(j+1); } int q1=publish(curq); 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-q1+i)/2; //std::cout<<"place = "<<place<<'\n'; 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...