Submission #1050168

# Submission time Handle Problem Language Result Execution time Memory
1050168 2024-08-09T07:49:07 Z shiomusubi496 The Collection Game (BOI21_swaps) C++17
5 / 100
297 ms 8512 KB
//
// --- 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 "swaps.h"
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); --i)
#define all(v) begin(v), end(v)
#define rall(v) rbegin(v), rend(v)

using namespace std;

using ll = long long;

template<class T, class U> bool chmin(T& a, const U& b) { return a > b ? a = b, true : false; }
template<class T, class U> bool chmax(T& a, const U& b) { return a < b ? a = b, true : false; }

mt19937 mt(random_device{}());

void solve(int N, int V) {
    vector<vector<int>> g(N);
    rep (_, V) {
        vector<int> P(N); iota(all(P), 0);
        shuffle(all(P), mt);
        rep (i, N / 2) schedule(P[i * 2] + 1, P[i * 2 + 1] + 1);
        auto res = visit();
        rep (i, N / 2) {
            if (res[i]) g[P[i * 2]].push_back(P[i * 2 + 1]);
            else g[P[i * 2 + 1]].push_back(P[i * 2]);
        }
    }
    vector<int> tps;
    {
        vector<bool> used(N);
        vector<int> ord;
        auto dfs = [&](auto&& self, int v) -> void {
            used[v] = true;
            for (int u : g[v]) if (!used[u]) self(self, u);
            ord.push_back(v);
        };
        rep (v, N) if (!used[v]) dfs(dfs, v);
        reverse(all(ord));
        tps = ord;
    }
    rep (i, N) ++tps[i];
    answer(tps);
}
# Verdict Execution time Memory Grader output
1 Correct 23 ms 596 KB Correct
2 Correct 83 ms 1620 KB Correct
3 Correct 135 ms 5056 KB Correct
4 Correct 249 ms 7700 KB Correct
5 Correct 239 ms 7644 KB Correct
6 Correct 246 ms 7320 KB Correct
7 Correct 238 ms 7756 KB Correct
8 Correct 258 ms 8092 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 592 KB Correct
2 Correct 81 ms 1608 KB Correct
3 Correct 142 ms 3980 KB Correct
4 Correct 253 ms 7832 KB Correct
5 Correct 242 ms 7384 KB Correct
6 Correct 297 ms 7484 KB Correct
7 Correct 241 ms 8512 KB Correct
8 Correct 248 ms 7832 KB Correct
9 Incorrect 49 ms 1936 KB Not correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 596 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 596 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 532 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 532 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 588 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 588 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 29 ms 524 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 29 ms 524 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 600 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 600 KB Not correct
2 Halted 0 ms 0 KB -