Submission #598060

#TimeUsernameProblemLanguageResultExecution timeMemory
598060jhnah917Art Collections (BOI22_art)C++17
50 / 100
771 ms536 KiB
#ifndef LOCAL #include "art.h" #endif #include <bits/stdc++.h> using namespace std; int inv; vector<int> tv; bool compare(int a, int b){ if(a == b) return false; swap(tv[a-1], tv[b-1]); int t = publish(tv); swap(tv[a-1], tv[b-1]); if(a < b) return inv < t; return inv > t; } 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[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){ tv.resize(n); iota(tv.begin(), tv.end(), 1); auto ord = tv; inv = publish(tv); 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...