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;
int try_it(int f, int s)
{
vector < int > rest;
for (int i = 1; i <= n; ++ i)
{
if(i == f || i == s)continue;
rest.push_back(i);
}
vector < int > fs, sf;
fs = rest;
fs.push_back(f);
fs.push_back(s);
int feedback1 = publish(fs);
sf = rest;
sf.push_back(s);
sf.push_back(f);
int feedback2 = publish(sf);
if(feedback1 < feedback2)
{
return 1;
}
else return 2;
}
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;
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:34:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
34 | while(i < f.size() && j < s.size())
| ~~^~~~~~~~~~
art.cpp:34:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
34 | while(i < f.size() && j < s.size())
| ~~^~~~~~~~~~
art.cpp:50:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
50 | while(i < f.size())
| ~~^~~~~~~~~~
art.cpp:55:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
55 | 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... |