Submission #853345

#TimeUsernameProblemLanguageResultExecution timeMemory
853345vjudge1Art Collections (BOI22_art)C++17
50 / 100
610 ms1316 KiB
#include "art.h" #include <bits/stdc++.h> using namespace std; int N, original; vector<int> order; bool smaller(int a, int b){ swap(order[a-1], order[b-1]); int nw = publish(order); swap(order[a-1], order[b-1]); if(a < b){ if(nw < original) { return false; //B is smaller. } else { return true; //A is smaller. } } else { if(nw < original) { return true; //A is smaller } else { return false; //B is smaller. } } } vector<int> merge_sort(int l, int r){ if(l == r){ if(l > N) return {}; else return {l}; } int m = (l + r) / 2; vector<int> left = merge_sort(l, m); vector<int> right = merge_sort(m + 1, r); vector<int> nw; int i = 0; int j = 0; while(i < (int)left.size() || j < (int)right.size()){ if(i >= (int)left.size()){ nw.push_back(right[j]); j++; }else if(j >= (int)right.size()){ nw.push_back(left[i]); i++; }else{ if(smaller(left[i], right[j])){ nw.push_back(left[i]); i++; }else{ nw.push_back(right[j]); j++; } } } return nw; } void solve(int n) { N = n; order.resize(N); for(int i = 0; i < N; i++) order[i] = i + 1; original = publish(order); int pw = 1; while(pw < N) pw *= 2; vector<int> ans = merge_sort(1, pw); 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...