Submission #867676

#TimeUsernameProblemLanguageResultExecution timeMemory
867676TAhmed33Art Collections (BOI22_art)C++17
50 / 100
608 ms1484 KiB
#include <bits/stdc++.h> using namespace std; #include "art.h" vector <int> arr; void merge (int l, int r) { if (l == r) return; int m = (l + r) / 2; merge(l, m); merge(m + 1, r); int x = publish(arr); int p1 = l, p2 = m + 1; vector <int> ans; while (p1 <= m && p2 <= r) { swap(arr[p1], arr[p2]); int u = publish(arr); if (u > x) { swap(arr[p1], arr[p2]); ans.push_back(arr[p1++]); } else { swap(arr[p1], arr[p2]); ans.push_back(arr[p2++]); x = u; } } while (p1 <= m) ans.push_back(arr[p1++]); while (p2 <= r) ans.push_back(arr[p2++]); for (int i = l; i <= r; i++) arr[i] = ans[i - l]; } void solve (int n) { for (int i = 1; i <= n; i++) arr.push_back(i); merge(0, n - 1); answer(arr); }

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