Submission #660113

#TimeUsernameProblemLanguageResultExecution timeMemory
660113ymmThe Collection Game (BOI21_swaps)C++17
0 / 100
2 ms284 KiB
#include "swaps.h" #include <bits/stdc++.h> #define Loop(x,l,r) for (ll x = (l); x < (ll)(r); ++x) #define LoopR(x,l,r) for (ll x = (r)-1; x >= (ll)(l); --x) typedef long long ll; typedef std::pair<int, int> pii; typedef std::pair<ll , ll > pll; using namespace std; const int LG = 9; const int N = 1<<LG; vector<int> ord; vector<pii> sched; int n; vector<int> cmp() { int cnt = 0; for (auto [i, j] : sched) { int x = ord[i]; int y = ord[j]; if (x > n || y > n) continue; schedule(x, y); ++cnt; } vector<int> res = cnt? visit(): vector<int>(), ans; reverse(res.begin(), res.end()); for (auto [i, j] : sched) { int x = ord[i]; int y = ord[j]; if (x > n || y > n) { ans.push_back(x < y); } else { ans.push_back(res.back()); res.pop_back(); } } sched.clear(); return ans; } void Do(int dis) { assert(N%dis == 0); Loop (i,0,N) { if ((i/dis)%2 == 0) sched.push_back({i, i+dis}); } auto res = cmp(); reverse(res.begin(), res.end()); Loop (i,0,N) { if ((i/dis)%2 == 0) { int x = res.back(); res.pop_back(); if (!x) swap(ord[i], ord[i+dis]); } } } void solve(int _n, int v) { n = _n; ord.resize(N); iota(ord.begin(), ord.end(), 1); LoopR (mx,0,LG) LoopR (i,0,mx+1) { Do(1<<i); } ord.resize(n); answer(ord); }
#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...