Submission #717773

#TimeUsernameProblemLanguageResultExecution timeMemory
717773Rafi22The Collection Game (BOI21_swaps)C++14
0 / 100
1 ms208 KiB
#include <bits/stdc++.h> #include "swaps.h" using namespace std; #define endl '\n' #define st first #define nd second #define pb push_back #define sz(x) (int)(x).size() #define all(x) (x).begin(), (x).end() #define ll long long ll mod=1000000007; int inf=1000000007; ll infl=1000000000000000007; const int N=507; void solve(int n,int v) { vector<vector<pair<int,int>>>res; vector<pair<int,int>>V; vector<int>ans(n); for(int i=0;i<n;i++) ans[i]=i+1; V.pb({1,n}); while(sz(V)>0) { vector<pair<int,int>>X; vector<vector<pair<int,int>>>T; for(auto [l,r]:V) X.pb({l,r}); while(sz(X)>0) { vector<pair<int,int>>nX,t; for(auto [l,r]:X) { int m=(l+r)/2; if(l<m) nX.pb({l,m}); if(m+1<r) nX.pb({m+1,r}); for(int i=0; m-i>=l&&m+i+1<=r;i++) t.pb({m-i,m+i+1}); } T.pb(t); X=nX; } reverse(all(T)); for(auto x:T) res.pb(x); vector<pair<int,int>>nV; for(auto [l,r]:V) { int m=(l+r)/2; if(l<m) nV.pb({l,m}); if(m+1<r) nV.pb({m+1,r}); } V=nV; } for(auto x:res) { for(auto [a,b]:x) schedule(a,b); vector<int>A=visit(); int it=0; for(auto [a,b]:x) { if(A[it]==0) swap(ans[a-1],ans[b-1]); it++; } } answer(ans); }

Compilation message (stderr)

swaps.cpp: In function 'void solve(int, int)':
swaps.cpp:30:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   30 |         for(auto [l,r]:V) X.pb({l,r});
      |                  ^
swaps.cpp:34:22: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   34 |             for(auto [l,r]:X)
      |                      ^
swaps.cpp:47:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   47 |         for(auto [l,r]:V)
      |                  ^
swaps.cpp:57:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   57 |         for(auto [a,b]:x) schedule(a,b);
      |                  ^
swaps.cpp:60:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   60 |         for(auto [a,b]:x)
      |                  ^
#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...