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;
/*
A = publish({x+1, x+2, ..., n, 1, 2, ..., x})
B = publish({x, x+1, x+2, ..., n, 1, 2, ..., x-1})
sol[x] = uni asl orderi
B = A + (sol[x] - 1) - (n - sol[x])
B = A - 1 - n + 2*sol[x]
sol[x] = (B-A+1+n)/2
*/
void solve(int n) {
vector<int> sol(n + 1), p(n);
iota(p.begin(), p.end(), 1);
int A = publish(p);
for (int i = n; i > 1; i--) {
p.insert(p.begin(), i); p.pop_back();
int B = publish(p);
assert((B - A + 1 + n) % 2 == 0);
sol[i] = (B - A + 1 + n) / 2;
A = B;
}
for (int i = 1; i <= n; i++) {
if (!count(sol.begin(), sol.end(), i)) {
sol[1] = i;
break;
}
}
vector<int> ans(n);
for (int i = 1; i <= n; i++) ans[sol[i] - 1] = i;
answer(ans);
}
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... |