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 <bits/stdc++.h>
using namespace std;
#define nl '\n'
#define pb push_back
#define fore(i , n) for(int i = 0 ; i< n;i++)
#define forr(i , x , y) for(int i = x; i <= y; i++)
#define forn(i , x , y) for(int i = x; i >= y ; i--)
vector<int> conv(deque<int> &dq)
{
vector<int> ans;
for(auto x :dq)
ans.pb(x);
return ans;
}
int publish(vector<int> v);
void answer(vector<int> v);
void solve(int N) {
deque<int> perm;
forr(i , 1 ,N)
{
perm.pb(i);
}
vector<int> pos(N + 1 , -1);
vector<int> final(N , -1);
int prev = publish(conv(perm));
forr(i , 1 , N - 1)
{
int l = perm.back();
perm.pop_back();
perm.push_front(l);
int nw = publish(conv(perm));
int after = (N - 1 + nw - prev)/2;
pos[l] = after;
prev = nw;
}
int missing = 0;
forr(i , 1 , N)
{
if(pos[i] == -1)
{
missing = i;
continue;
}
final[pos[i]] = i;
}
fore(i , N)
{
if(final[i] == -1)
final[i] = missing;
}
answer(final);
}
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... |