Submission #702412

#TimeUsernameProblemLanguageResultExecution timeMemory
702412jamezzzThe Collection Game (BOI21_swaps)C++17
0 / 100
1 ms208 KiB
#include "swaps.h" #include <bits/stdc++.h> using namespace std; bool in[1005]; vector<int> v; vector<pair<int,int>> asks; void compute(){ auto res=visit(); reverse(res.begin(),res.end()); for(auto[a,b]:asks){ if(res.back()==0)swap(v[a],v[b]); res.pop_back(); in[a]=in[b]=false; } } void solve(int N,int V){ for(int i=1;i<=N;++i){ v.push_back(i); } for(int p=1;p<=N;p<<=1){ for(int k=p;k>=1;k>>=1){ for(int j=k%p;j<=N-1-k;j+=2*k){ for(int i=0;i<=k-1;++i){ if((i+j)/(2*p)==(i+j+k)/(2*p)&&i+j+k<N){ if(in[v[i+j]]||in[v[i+j+k]])compute(); schedule(v[i+j],v[i+j+k]); in[v[i+j]]=in[v[i+j+k]]=true; asks.push_back({v[i+j],v[i+j+k]}); } } } } } answer(v); }
#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...