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;
vector<int> rel = {2, 3, 1, 4, 5};
// 2 3 1 4 5
void solve(int N) {
vector<int> order(N);
for(int i = 0; i < N; i++) order[i] = i + 1;
vector<int> dif(N, 0);
int mx = 0;
for(int i = 1; i < N; i++){
swap(order[i-1], order[0]);
// swap(rel[i-1], rel[0]);
int original = publish(order);
swap(order[0], order[N - 1]);
int nw = publish(order);
swap(order[0], order[N - 1]);
// cout << "I " << i << " nw "<< nw << " original " << original << " dif "<< dif[i-1] << " dif halved " << dif[i-1] / 2 << endl;
if(original > nw){
//N-1 is smaller than 0.
original++;
}else{
//0 is smaller than N-1.
nw++;
}
// swap(rel[0], rel[N-1]);
// for(int x : rel) cout << x << " ";
// cout << endl;
// swap(rel[0], rel[N-1]);
dif[i-1] = original - nw;
// cout << "I " << i << " nw "<< nw << " original " << original << " dif "<< dif[i-1] << " dif halved " << dif[i-1] / 2 << endl;
dif[i-1] /= 2;
mx = max(mx, dif[i-1]);
}
vector<int> ans(N);
ans[N-1] = N - mx;
vector<int> real_ans(N);
for(int i = 0; i < N; i++){
ans[i] = ans[N-1] + dif[i];
real_ans[ans[i]-1] = i + 1;
}
answer(real_ans);
}
/*
10
9 10 3 1 2 4 8 7 6 5
*/
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... |