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;
//
// --- Sample implementation for the task art ---
//
// To compile this program with the sample grader, place:
// art.h art_sample.cpp sample_grader.cpp
// in a single folder, then open the terminal in this directory (right-click onto an empty spot in the directory,
// left click on "Open in terminal") and enter e.g.:
// g++ -std=c++17 art_sample.cpp sample_grader.cpp
// in this folder. This will create a file a.out in the current directory which you can execute from the terminal
// as ./a.out
// See task statement or sample_grader.cpp for the input specification
//
int cur_ans;
vector<int> v, cur_query;
bool comp(int i, int j) {
swap(cur_query[i - 1], cur_query[j - 1]);
int tmp_ans = publish(cur_query);
swap(cur_query[i - 1], cur_query[j - 1]);
if (tmp_ans < cur_ans) return false;
return true;
}
vector<int> merge_sort(int l, int r) {
if (r < l) return {};
if (l == r) return {v[l]};
int mid = (l + r) / 2;
auto left = merge_sort(l, mid);
auto right = merge_sort(mid + 1, r);
vector<int> ret;
int i = 0, j = 0;
while (i < left.size() && j < right.size()) {
if (comp(left[i], right[j])) ret.push_back(left[i++]);
else ret.push_back(right[j++]);
}
while (i < left.size()) ret.push_back(left[i++]);
while (j < right.size()) ret.push_back(right[j++]);
return ret;
}
void solve(int N) {
v.resize(N);
cur_query.resize(N);
iota(begin(cur_query), end(cur_query), 1);
iota(begin(v), end(v), 1);
cur_ans = publish(v);
auto ans = merge_sort(0, N - 1);
answer(ans);
}
Compilation message (stderr)
art.cpp: In function 'std::vector<int> merge_sort(int, int)':
art.cpp:36:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
36 | while (i < left.size() && j < right.size()) {
| ~~^~~~~~~~~~~~~
art.cpp:36:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
36 | while (i < left.size() && j < right.size()) {
| ~~^~~~~~~~~~~~~~
art.cpp:40:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
40 | while (i < left.size()) ret.push_back(left[i++]);
| ~~^~~~~~~~~~~~~
art.cpp:41:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
41 | while (j < right.size()) ret.push_back(right[j++]);
| ~~^~~~~~~~~~~~~~
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... |