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;
//solve function
void solve(int n) {
//std::vector<int> order = {1, 2, 3};
//publish(order);
//order = {2, 3, 1};
//publish(order);
//order = {1, 3, 2};
//answer(order);
deque<int>d;
vector<int>storage;
for(int x=1;x<=n;x++){
d.push_back(x);
storage.push_back(x);
}
int ans[n+5];
memset(ans,-1,sizeof(ans));
int last=publish(storage);
for(int x=1;x<n;x++){
vector<int>cur;
d.push_front(d.back());
d.pop_back();
for(auto it:d){
cur.push_back(it);
}
int hold=publish(cur);
//show2(last,last,hold,hold);
int index=1+(n-1-(last-hold))/2;
//show(index,index);
ans[index]=d.front();
last=hold;
}
vector<int>amos;
for(int x=1;x<=n;x++){
if(ans[x]==-1){
amos.push_back(d.back());
}
else{
amos.push_back(ans[x]);
}
}
answer(amos);
}
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... |