Submission #1050176

#TimeUsernameProblemLanguageResultExecution timeMemory
1050176shiomusubi496The Collection Game (BOI21_swaps)C++17
0 / 100
1 ms344 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 "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); rep2 (k, 1, N) { rep (i, N) { if (i / k % 2 == 1) continue; if (i + k < N) schedule(i + 1, i + k + 1); } auto res = visit(); rep (i, res.size()) { if (res[i]) g[i].push_back(i + k); else g[i + k].push_back(i); } rep (i, N) { if (i / k % 2 == 0) continue; if (i + k < N) schedule(i + 1, i + k + 1); } res = visit(); rep (i, res.size()) { if (res[i]) g[i].push_back(i + k); else g[i + k].push_back(i); } } 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 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...