# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
648374 | 2022-10-06T09:16:53 Z | berr | The Collection Game (BOI21_swaps) | C++17 | 1 ms | 208 KB |
#include <bits/stdc++.h> #include "swaps.h" using namespace std; void solve(int N, int V) { if(V=5000) { vector<int> vis(N+1); vector<int> ans; for(int x=0; x<N; x++) { vector<int> q; for(int i=1; i<=N; i++) { if(!vis[i]) q.push_back(i); } while(q.size()>1) { for(int l=0; l<q.size()-1; l++) { schedule(q[l], q[l+1]); } auto b=visit(); vector<int> p; for(int l=0; l<b.size(); l++) { if(b[l]==1) p.push_back(q[l*2-1]); else p.push_back(q[l*2]); } if(q.size()%2==1) p.push_back(q[q.size()-1]) ; q=p; } vis[q[0]]=1; ans.push_back(q[0]); } answer(ans); } else { vector<array<int, 2>> a[V]; vector<vector<int>> vis(V, vector<int>(N+1)); vector<vector<int>> c(N+1, vector<int>(N+1)); for(int i=1; i<=N; i++) { for(int l=i+1; l<=N; l++) { int flag=1; for(int j=0; j<V&&flag; j++) { if(vis[j][i]==0&&vis[j][l]==0) { a[j].push_back({i, l}); vis[j][i]=1; vis[j][l]=1; flag=0; } } } } for(int i=0; i<V&&a[i].size(); i++) { for(auto l: a[i]) schedule(l[0], l[1]); auto b=visit(); for(int l=0; l<a[i].size(); l++) { if(b[l]==1) c[a[i][l][0]][a[i][l][1]]=1, c[a[i][l][1]][a[i][l][0]]=0; else c[a[i][l][0]][a[i][l][1]]=0, c[a[i][l][1]][a[i][l][0]]=1; } } vector<array<int, 2>> q; vector<int> s; for(int i=1; i<=N; i++) { int l=0; for(auto j: c[i]) if(j==0) l++; q.push_back({l, i}); } sort(q.begin(), q.end()); for(auto i: q) s.push_back(i[1]); answer(s); } }
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 | 0 ms | 208 KB | Not correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 208 KB | Not correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 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 | 0 ms | 208 KB | Not correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 208 KB | Not correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 208 KB | Not correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 208 KB | Not correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 208 KB | Not correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 208 KB | Not correct |
2 | Halted | 0 ms | 0 KB | - |