제출 #1177268

#제출 시각아이디문제언어결과실행 시간메모리
1177268DON_FArt Collections (BOI22_art)C++20
20 / 100
55 ms428 KiB
#include "art.h"
//
// --- 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
//

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) x.begin(), x.end()
#define L(i, b, e) for (int i = b; i < e; ++i)
#define R(i, b, e) for (int i = b; i >= e; --i)
#define pb emplace_back
#define vi vector<int>
#define sz(x) ((int) x.size())

void solve(int n) {
    /*std::vector<int> order = {1, 2, 3};
    publish(order);
    order = {2, 3, 1};
    publish(order);
    order = {1, 3, 2};
    answer(order);*/
    vi in(n + 1);
    vector<vi> g(n + 1);
    L(i, 1, n + 1){
        L(j, i + 1, n + 1){
            vi b;
            b.pb(i);
            b.pb(j);
            L(k, 1, n + 1)if (k != i && k != j)b.pb(k);
            int v1 = publish(b);
            swap(b[0], b[1]);
            int v2 = publish(b);
            if (v1 < v2){
                g[i].pb(j);
                in[j]++;
            }else{
                g[j].pb(i);
                in[i]++;
            }
        }
    }
    vi res;
    L(i, 1, n + 1){
        if (in[i] == 0){
            res.pb(i);
        }
    }
    while (sz(res) < n){
        int x = res.back();
        for (auto &i : g[x]){
            in[i]--;
            if (in[i] == 0)res.pb(i);
        }
    }
    answer(res);
}
#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...