Submission #721034

#TimeUsernameProblemLanguageResultExecution timeMemory
721034JohannThe Collection Game (BOI21_swaps)C++14
35 / 100
64 ms536 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> using namespace std; #define ll long long #define pii pair<int, int> #define vb vector<bool> #define vi vector<int> #define vpii vector<pii> #define vvb vector<vb> #define vvi vector<vi> #define vvpii vector<vpii> #define sz(x) (int)(x).size() int N, V; void solve(int _N, int _V) { N = _N, V = _V; vvi ans(N); vi todo; for (int i = 1; i <= N; ++i) todo.push_back(i); ans[0].push_back(todo.back()), todo.pop_back(); if (N > 1) ans[0].push_back(todo.back()), todo.pop_back(); while (sz(ans.back()) == 0) { for (int i = 0; i < N; ++i) if (sz(ans[i]) > 1) schedule(ans[i][0], ans[i][1]); vi v = visit(); for (int i = N - 1; i >= 0; --i) if (sz(ans[i]) > 1) { if (!v.back()) swap(ans[i][0], ans[i][1]); v.pop_back(); } for (int i = N - 2; i >= 0; --i) if (sz(ans[i]) > 1) ans[i + 1].push_back(ans[i].back()), ans[i].pop_back(); if (sz(todo) > 0) ans[0].push_back(todo.back()), todo.pop_back(); } vi formalAns; for (int i = 0; i < N; ++i) formalAns.push_back(ans[i][0]); answer(formalAns); }
#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...