# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
717779 | 2023-04-02T14:06:39 Z | Rafi22 | The Collection Game (BOI21_swaps) | C++14 | 1 ms | 208 KB |
#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; /* int p[N]; vector<pair<int,int>>tmp; void schedule(int a,int b) { tmp.pb({a,b}); } vector<int>visit() { vector<int>res; for(auto x:tmp) res.pb(p[x.st]>p[x.nd]); tmp.clear(); return res; } void answer(vector<int>V) { for(auto x:V) cout<<x<<" "; cout<<endl; }*/ 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(ans[a-1],ans[b-1]); 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); } /* int main() { int n; cin>>n; for(int i=1;i<=n;i++) cin>>p[i]; solve(n,0); return 0; }*/
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 208 KB | Not correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 208 KB | Not correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 208 KB | Not correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 208 KB | Not correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 208 KB | Not correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 208 KB | Not correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 208 KB | Not correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 208 KB | Not correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 208 KB | Not correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 208 KB | Not correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 208 KB | Not correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 208 KB | Not correct |
2 | Halted | 0 ms | 0 KB | - |