Submission #576921

#TimeUsernameProblemLanguageResultExecution timeMemory
576921CSQ31The Collection Game (BOI21_swaps)C++17
0 / 100
1 ms464 KiB
#include "swaps.h" #include <bits/stdc++.h> #define sz(a) (int)(a.size()) #define pb push_back using namespace std; int nn,pw = 1; vector<int>v; void bitonic(int n){ if(n==1)return; int z = n/2; for(int i=0;i<pw;i+=2*z){ for(int j=i;j<i+z;j++){ if(max(v[j],v[j+z]) <= nn)schedule(v[j],v[j+z]); } } vector<int>res = visit(); int k = 0; for(int i=0;i<pw;i+=2*z){ for(int j=i;j<i+z;j++){ if(max(v[j],v[j+z]) <= nn){ if(!res[k])swap(v[j],v[j+z]); k++; }else if(v[j] >nn)swap(v[j],v[j+z]); } } bitonic(n/2); } void merge(int n){ if(n==1)return; merge(n/2); int z = n/2; cout<<n<<'\n'; for(int i=0;i<pw;i+=2*z){ for(int j=i;j<i+z;j++){ if(max(v[j],v[j+z]) <= nn)schedule(v[j],v[j+z]); } } vector<int>res = visit(); int k = 0; for(int i=0;i<pw;i+=2*z){ for(int j=i;j<i+z;j++){ if(max(v[j],v[j+z]) <= nn){ if(!res[k])swap(v[j],v[j+z]); k++; } } for(int j=i+z;j<i+2*z;j++){ int inv = j-i-z; inv = z-inv-1; inv = i+z+inv; if(inv > j)swap(v[j],v[inv]); } } bitonic(n); } void solve(int n,int V){ nn = n; while(pw<n)pw*=2; for(int i=1;i<=pw;i++)v.push_back(i); merge(pw); vector<int>fin; for(int x:v)if(x<=n)fin.pb(x); answer(fin); }
#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...