Submission #510050

#TimeUsernameProblemLanguageResultExecution timeMemory
510050ElegiaThe Collection Game (BOI21_swaps)C++17
100 / 100
6 ms412 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 <cstdarg> #include <cstdio> #include <cstdlib> #include <set> #include <vector> #include <algorithm> #include <numeric> #include "swaps.h" using namespace std; void solve(int N, int V) { vector<int> ans(N); iota(ans.begin(), ans.end(), 1); for (int p = 1; p < N; p *= 2) for (int k = p; k; k /= 2) { for (int j = k % p; j <= N - k - 1; j += k * 2) for (int i = 0; i <= min(k - 1, N - j - k - 1); ++i) if ((i + j) / (p * 2) == (i + j + k) / (p * 2)) schedule(ans[i + j], ans[i + j + k]); vector<int> res = visit(); int cnt = 0; for (int j = k % p; j <= N - k - 1; j += k * 2) for (int i = 0; i <= min(k - 1, N - j - k - 1); ++i) if ((i + j) / (p * 2) == (i + j + k) / (p * 2)) if (!res[cnt++]) swap(ans[i + j], ans[i + j + k]); } 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...