#include "art.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> order;
int r1;
void _merge(int l, int m, int r)
{
int n1 = m-l+1;
int n2 = r-m;
vector<int> L(n1), R(n2);
vector<int> order1=order;
for(int i = 0; i < n1; i++) L[i] = order[l+i];
for(int i = 0; i < n2; i++) R[i] = order[m+1+i];
int i = 0, j = 0;
int k = l;
while(i < n1 && j < n2)
{
swap(order1[l+i], order1[m+1+j]);
int r2 = publish(order1);
if(r2==0)
{
answer(order1);
}
swap(order1[l+i], order1[m+1+j]);
if(r1 < r2)
{
order[k] = L[i];
i++;
}
else
{
order[k]=R[j];
j++;
}
k++;
}
while(i < n1)
{
order[k] = L[i];
i++;
k++;
}
while(j < n2)
{
order[k] = R[j];
j++;
k++;
}
}
void ms(int l, int r)
{
if(l >= r) return;
int m = l+(r-l)/2;
ms(l, m);
ms(m+1, r);
_merge(l, m, r);
}
void solve(int N) {
for (int i = 1; i <= N; i++)
{
order.push_back(i);
}
r1= publish(order);
if(r1==0)
{
answer(order);
}
ms(0, N-1);
answer(order);
}
//publish
//answer
# | 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... |