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>
#include "art.h"
using namespace std;
int n;
vector < int > init;
int inits;
int try_it(int f, int s)
{
int turn = 1, change = 2;
if(f > s)
{
swap(turn, change);
}
vector < int > sf = init;
swap(sf[f-1], sf[s-1]);
int feedback1 = publish(sf);
if(inits > feedback1)
{
turn = change;
}
return turn;
}
vector < int > combine(vector < int > f, vector < int > s)
{
vector < int > res;
int i = 0;
int j = 0;
while(i < f.size() && j < s.size())
{
int el1 = f[i];
int el2 = s[j];
int order = try_it(el1, el2);
if(order == 1)
{
res.push_back(el1);
i ++;
}
else
{
res.push_back(el2);
j ++;
}
}
while(i < f.size())
{
res.push_back(f[i]);
i ++;
}
while(j < s.size())
{
res.push_back(s[j]);
j ++;
}
return res;
}
vector < int > merge_sort(int l, int r)
{
if(l == r)
{
vector < int > v;
v.push_back(l);
return v;
}
int mid = (l + r)/2;
vector < int > fh, sh;
fh = merge_sort(l, mid);
sh = merge_sort(mid+1, r);
return combine(fh, sh);
}
void solve(int N)
{
n = N;
for (int i = 1; i <= n; ++ i)
init.push_back(i);
inits = publish(init);
vector < int > v = merge_sort(1, n);
answer(v);
return;
}
Compilation message (stderr)
art.cpp: In function 'std::vector<int> combine(std::vector<int>, std::vector<int>)':
art.cpp:31:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
31 | while(i < f.size() && j < s.size())
| ~~^~~~~~~~~~
art.cpp:31:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
31 | while(i < f.size() && j < s.size())
| ~~^~~~~~~~~~
art.cpp:47:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
47 | while(i < f.size())
| ~~^~~~~~~~~~
art.cpp:52:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
52 | while(j < s.size())
| ~~^~~~~~~~~~
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... |