Submission #1325892

#TimeUsernameProblemLanguageResultExecution timeMemory
1325892sh_qaxxorov_571Art Collections (BOI22_art)C++20
0 / 100
0 ms332 KiB
#include "art.h"
#include <vector>
#include <algorithm>

void solve(int N) {
    std::vector<int> current_order(N);
    for (int i = 0; i < N; ++i) {
        current_order[i] = i + 1;
    }

    // Dastlabki shikoyatlar sonini olish
    int last_v = publish(current_order);
    
    // Har bir element (2 dan N gacha) uchun uning o'rnini aniqlaymiz
    // Har bir qadamda bitta elementni ro'yxat boshiga o'tkazamiz
    for (int i = 2; i <= N; ++i) {
        std::vector<int> next_order;
        next_order.push_back(i);
        for (int x : current_order) {
            if (x != i) next_order.push_back(x);
        }
        
        int current_v = publish(next_order);
        
        // i-elementidan oldin bo'lishi kerak bo'lgan elementlar soni:
        // Formula: (Shikoyatlar farqi + (N-1)) / 2 ga asoslangan mantiq
        int pos = (last_v - current_v + (N - 1)) / 2;
        
        // i elementini o'zining haqiqiy o'rniga (pos) joylashtiramiz
        std::vector<int> updated_order;
        int count = 0;
        for (int x : current_order) {
            if (x == i) continue;
            if (count == pos) updated_order.push_back(i);
            updated_order.push_back(x);
            count++;
        }
        if (count == pos) updated_order.push_back(i);
        
        current_order = updated_order;
        last_v = current_v;
    }

    answer(current_order);
}
#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...