Submission #1234216

#TimeUsernameProblemLanguageResultExecution timeMemory
1234216retr0baltArt Collections (BOI22_art)C++20
20 / 100
54 ms408 KiB
#include "art.h"

#include <algorithm>
#include <iostream>

/*
i misread the fucking problem are you serious
*/

void s3merge(std::vector<int> &order, int l, int r)
{
    if (l == r) return;
    
    int m = (l+r)/2;    
    int l1 = l, r1 = m, l2 = m+1, r2 = r;

    s3merge(order, l1, r1);
    s3merge(order, l2, r2);
    int js = l1;
    for (int i = l2; i <= r2; ++i)
    {
        int current = order[i];
        order.erase(order.begin() + i);
        order.insert(order.begin() + js, current);
        
        int cans = publish(order);
        for (int j = js; j < i; ++j)
        {
            std::swap(order[j], order[j+1]);
            int kans = publish(order);
            if (kans > cans)
            {
                std::swap(order[j], order[j+1]);
                js = j+1;
                break;
            }
            cans = kans;
        }
    }
}

void solve3(int N)
{
    
    std::vector<int> order;
    for (int i = 1; i <= N; ++i)
    {
        order.push_back(i);
    }
    
    s3merge(order, 0, order.size() - 1);
    answer(order);
}

void solve(int N) {
    solve3(N);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...