# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
575815 | 2022-06-11T10:06:52 Z | CSQ31 | The Collection Game (BOI21_swaps) | C++17 | 0 ms | 0 KB |
#include "swaps.h" #include <bits/stdc++.h> using namespace std; void solve(int n,int V){ vector<int>cur; vector<int>ans; for(int i=1;i<=n;i++)cur.push_back(i); for(int i=1;i<n;i++){ vector<int>v = cur; while(sz(v)>1){ vector<int>nw; int m = sz(v); for(int j=0;j+1<m;j+=2)schedule(v[j],v[j+1]); vector<int>res = visit(); int c = 0; for(int j=0;j+1<m;j+=2){ if(res[c])nw.push_back(v[j+1]); else nw.push_back(v[j]); c++; } if(m&1)nw.push_back(v.back()); v = nw; } ans.push_back(v.back()); v.clear(); for(int x:cur){ if(x!=ans.back())v.push_back(x); } cur = v; } ans.push_back(cur.back()); reverse(ans.begin(),ans.end()); answer(ans); }