Submission #1327098

#TimeUsernameProblemLanguageResultExecution timeMemory
1327098husseinjuandaArt Collections (BOI22_art)C++20
100 / 100
689 ms464 KiB
#include "art.h"
#include <bits/stdc++.h>
using namespace std;
//
// --- Sample implementation for the task art ---
//
// To compile this program with the sample grader, place:
//     art.h art_sample.cpp sample_grader.cpp
// in a single folder, then open the terminal in this directory (right-click onto an empty spot in the directory,
// left click on "Open in terminal") and enter e.g.:
//     g++ -std=c++17 art_sample.cpp sample_grader.cpp
// in this folder. This will create a file a.out in the current directory which you can execute from the terminal
// as ./a.out
// See task statement or sample_grader.cpp for the input specification
//
void solve(int n){
    vector<int> ord(n);
    for(int i = 0; i < n; i++){
        ord[i] = i+1;
    }
    int base = publish(ord);
    vector<int> inv(n);
    for(int i = 2; i <= n; i++){
        ord = {i};
        for(int y = 1; y <= n; y++){
            if(i == y) continue;
            ord.push_back(y);
        }
        int w = base - publish(ord);
        inv[i-1] = ((i-1) - w)/2 + w;
    }
    vector<int> ans(n);
    int rn = n-1;
    vector<bool> d(n);
    for(int y = n-1; y >= 0; y--){
        int it = n-1;
        while(d[it] || inv[y] > 0){
            if(!d[it]){
                inv[y]--;
            }
            it--;
        }
        ans[it] = y+1;
        d[it] = true;
        while(d[rn]){
            rn--;
            if(rn == -1) break;
        }
    }
    // for(int i = 0; i < n; i++){
    //     cout << ans[i] << " ";
    // }cout << "\n";
    answer(ans);
}
#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...