Submission #1214062

#TimeUsernameProblemLanguageResultExecution timeMemory
1214062ProtonDecay314The Collection Game (BOI21_swaps)C++20
0 / 100
1 ms416 KiB
//
// --- Sample implementation for the task swaps ---
//
// To compile this program with the sample grader, place:
//     swaps.h swaps_sample.cpp sample_grader.cpp
// in a single folder and run:
//     g++ swaps_sample.cpp sample_grader.cpp
// in this folder.
//
#include <bits/stdc++.h>
#include "swaps.h"
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pi;
typedef vector<pi> vpi;
typedef vector<bool> vb;
#define INF(dt) numeric_limits<dt>::max()
#define NINF(dt) numeric_limits<dt>::min()
#define pb push_back

void printv(const vi& a) {
    for(int v : a) cerr << v << " ";
    cerr << endl;
}

vi cur_labels;

void schedule_and_visit(const vpi& pairs) {
    if(pairs.size() == 0) return;

    for(auto& [p1, p2] : pairs) {
        schedule(cur_labels[p1] + 1, cur_labels[p2] + 1);
    }

    vi vis_results = visit();

    int ps = pairs.size();

    for(int i = 0; i < ps; i++) {
        if(vis_results[i] == 0) {
            swap(cur_labels[pairs[i].first], cur_labels[pairs[i].second]);
        }
    }
}

void solve(int N, int V) {
    vi labels(N, 0);
    for(int i = 0; i < N; i++) labels[i] = i;
    cur_labels = labels;

    for(int i = 8; i >= 0; i--) {
        int mask = 1 << i;
        for(int j = 0; j <= i; j++) {
            vpi to_sched;
            
            for(int k = 0; k < N; k++) {
                int other = k ^ mask;

                if(other < N) {
                    pi to_insert = {k, other};
                    
                    if(to_insert.first < to_insert.second) to_sched.pb(to_insert);
                }
                
            }
            schedule_and_visit(to_sched);
            mask ^= 1 << j;
        }
    }

    // if(N >= 3) {
    //     for(int i = 0; i < N; i++) {
    //         int par = (N + i) & 0b1;

    //         vpi to_sched;

    //         for(int j = par; j < N - 1; j += 2) {
    //             to_sched.pb({j, j + 1});
    //         }

    //         schedule_and_visit(to_sched);
    //     }
    // } else if(N == 2) {
    //     schedule_and_visit({{0, 1}});
    // }

    vi ans(N, 0);

    for(int i = 0; i < N; i++) ans[i] = cur_labels[i] + 1;

    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...
#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...