Submission #598044

#TimeUsernameProblemLanguageResultExecution timeMemory
598044jhnah917Art Collections (BOI22_art)C++17
35 / 100
192 ms288 KiB
#include "art.h" #include <bits/stdc++.h> using namespace std; bool compare(vector<int> &ord, int a, int b){ if(a == b) return false; int pa = find(ord.begin(), ord.end(), a) - ord.begin(); int pb = find(ord.begin(), ord.end(), b) - ord.begin(); int t1 = publish(ord); swap(ord[pa], ord[pb]); int t2 = publish(ord); swap(ord[pa], ord[pb]); return t1 < t2; } void merge_sort(vector<int> &ord, int s, int e){ if(s >= e) return; int m = (s + e) / 2; merge_sort(ord, s, m); merge_sort(ord, m+1, e); vector<int> tmp(ord.size()); int i = s, j = m+1, k = s; while(i <= m && j <= e){ if(compare(ord, ord[i], ord[j])) tmp[k++] = ord[i++]; else tmp[k++] = ord[j++]; } while(i <= m) tmp[k++] = ord[i++]; while(j <= e) tmp[k++] = ord[j++]; for(k=s; k<=e; k++) ord[k] = tmp[k]; } void solve(int n){ vector<int> ord(n); iota(ord.begin(), ord.end(), 1); merge_sort(ord, 0, n-1); answer(ord); }

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