Submission #550141

#TimeUsernameProblemLanguageResultExecution timeMemory
550141fcmalkcinThe Collection Game (BOI21_swaps)C++17
100 / 100
10 ms484 KiB
#include "swaps.h" #include<bits/stdc++.h> using namespace std; #define ll int #define pll pair<ll,ll> #define ff first #define ss second #define endl "\n" #define pb push_back #define F(i,a,b) for(ll i=a;i<=b;i++) const ll maxn=3e5+10 ; const ll base=1e9; const ll mod= 1e9+7 ; mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); /// have medal in APIO /// goal 2/8 ll len; ll cnt=0; vector<pll> vt; map<pll,ll> mp; ll a[maxn]; ll b[maxn]; void get() { vector<ll> vt1=visit(); for (int t=0; t<vt1.size(); t++) { mp[vt[t]]=vt1[t]; } vt.clear(); } void setup(ll x, ll y) { if (x<=len&&y<=len) { schedule(x,y); vt.pb(make_pair(x,y)); } else { if (x>len&&y>len) { mp[make_pair(x,y)]=(x>y); } else if (x>len) { mp[make_pair(x,y)]=0; } else { mp[make_pair(x,y)]=1; } } } void ans(vector<ll> vt) { answer(vt); } void solve(ll n,ll v) { ll p=1; while (p<n) p*=2; len=n; vector<ll> vt; for (int t=1; t<=p; t++) vt.pb(t); for (int t=2; t<=p; t*=2) { vector<vector<ll>> vt1; for (int i=1; i<=p; i+=t) { vector<ll> vt2; for (int k=i; k<=i+t/2-1; k++) { vt2.pb(vt[k-1]); } for (int k=i+t-1; k>=i+t/2; k--) { vt2.pb(vt[k-1]); } vt1.pb(vt2); } while (vt1[0].size()!=1) { mp.clear(); ll len=vt1[0].size(); for (auto p:vt1) { for (int i=0; i<len/2; i++) { setup(p[i],p[i+len/2]); } } get(); vector<vector<ll>> vt2; for (auto p1:vt1) { vector<ll> p=p1; assert(p.size()==len); for (int i=0; i<len/2; i++) { if (mp[make_pair(p[i],p[i+len/2])]==0) swap(p[i],p[i+len/2]); } vector<ll> vtnxt1; vector<ll> vtnxt2; for (int i=0; i<len/2; i++) { vtnxt1.pb(p[i]); } for (int i=len/2; i<len; i++) { vtnxt2.pb(p[i]); } vt2.pb(vtnxt1); vt2.pb(vtnxt2); } swap(vt1,vt2); /* cout <<t<<" "<<len<<" kt"<<endl; for (int i=1; i<=n; i++) { cout <<a[i]<<" "; } cout <<endl; for (auto to:vt1) { for (auto h:to) cout <<h<<" "; cout <<endl; } cout <<endl;*/ } vt.clear(); for (auto p:vt1) { vt.pb(p[0]); } } vector<ll> res; for (int i=0; i<n; i++) res.pb(vt[i]); ans(res); } /*int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen("test.inp","r")) { freopen("test.inp","r",stdin); freopen("test.out","w",stdout); } }*/

Compilation message (stderr)

swaps.cpp: In function 'void get()':
swaps.cpp:34:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     for (int t=0; t<vt1.size(); t++)
      |                   ~^~~~~~~~~~~
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from swaps.cpp:4:
swaps.cpp: In function 'void solve(int, int)':
swaps.cpp:108:32: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  108 |                 assert(p.size()==len);
      |                        ~~~~~~~~^~~~~
#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...