Submission #398488

#TimeUsernameProblemLanguageResultExecution timeMemory
398488model_codeThe Collection Game (BOI21_swaps)C++17
100 / 100
8 ms388 KiB
#include "swaps.h" #include <bits/stdc++.h> using namespace std; vector<int> r; vector<pair<int, int>> queries; void scheduleSortingNetwork(int i, int j) { schedule(r[i], r[j]); queries.emplace_back(i, j); } void visitSortingNetwork() { if (queries.size() == 0) return; vector<int> res = visit(); for (int i = 0; i < (int) res.size(); i++) if (!res[i]) swap(r[queries[i].first], r[queries[i].second]); queries.clear(); } void answerSortingNetwork() { answer(r); } void solve(int N, int Q) { for (int i = 1; i <= N; i++) r.push_back(i); for (int k = 2; k <= 2 * N; k <<= 1) { for (int i = 0; i < N; i++) { int l = i ^ (k - 1); if (i < l && l < N) scheduleSortingNetwork(i, l); } visitSortingNetwork(); for (int j = k >> 2; j > 0; j >>= 1) { for (int i = 0; i < N; i++) { int l = i ^ j; if (i < l && l < N) scheduleSortingNetwork(i, l); } visitSortingNetwork(); } } answerSortingNetwork(); }
#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...