This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |