Submission #1237327

#TimeUsernameProblemLanguageResultExecution timeMemory
1237327warrennArt Collections (BOI22_art)C++20
100 / 100
766 ms504 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
//

vector<int>ord;

void solve(){
    vector<int>cur;
    for(int q=1;q<ord.size();q++){
        cur.push_back(ord[q]);
    }
    cur.push_back(ord[0]);
    ord=cur;
}

void solve(int n){
    for(int q=1;q<=n;q++){
        ord.push_back(q);
    }
    int cur=publish(ord);
    int ans[n+1];
    memset(ans,0,sizeof ans);
    for(int q=1;q<n;q++){
        solve();
        int baru=publish(ord);
        int slsh=baru-cur;
        if(n%2==0){
            if(slsh>0){
                int grk=(slsh-1)/2;
                ans[n/2-grk]=q;
            }
            else{
                int grk=(slsh-1)/2;
                grk=abs(grk);
                ans[n/2+grk]=q;
            }
        }
        else{
            int mid=(n+1)/2;
            if(slsh>0){
                int grk=slsh/2;
                ans[mid-grk]=q;
            }
            else{
                int grk=slsh/2;
                grk=abs(grk);
                ans[mid+grk]=q;
            }
        }
        // cout<<slsh<<" "<<q<<endl;
        cur=baru;
    }
    for(int q=1;q<=n;q++){
        if(ans[q]==0)ans[q]=n;
    }
    vector<int>akh;
    for(int q=1;q<=n;q++){
        akh.push_back(ans[q]);
    }
    return answer(akh);
}
#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...