Submission #648402

#TimeUsernameProblemLanguageResultExecution timeMemory
648402berrThe Collection Game (BOI21_swaps)C++17
0 / 100
1 ms208 KiB
#include <bits/stdc++.h> #include "swaps.h" using namespace std; void solve(int N, int V) { deque<vector<int>> ans(1); for(int i=1; i<=N; i++) { ans[0].push_back(i); } int l=0, r=N-1; vector<int> q(N); while(ans.size()) { for(int i=0; i<ans.size(); i++) { for(int l=0; l<ans[i].size()-1; l+=2) { schedule(ans[i][l], ans[i][l+1]); } } deque<vector<int>> br(ans.size()+1); auto b=visit(); int f=0; for(int i=0; i<ans.size(); i++) { for(int l=0; l<ans[i].size()-1; l+=2) { if(b[f]==1) br[i].push_back(ans[i][l]), br[i+1].push_back(ans[i][l+1]); else br[i].push_back(ans[i][l+1]), br[i+1].push_back(ans[i][l]); f++; } if(ans[i].size()%2) br[i].push_back(ans[i][ans[i].size()-1]); } ans=br; int k=0; while(ans.size()&&ans[0].size()==1) { q[l]=ans[0][0]; ans.pop_front(); l++; } while(ans.size()&&ans[ans.size()-1].size()==1) { q[r]=ans[ans.size()-1][0]; ans.pop_back(); r--; } } answer(q); }

Compilation message (stderr)

swaps.cpp: In function 'void solve(int, int)':
swaps.cpp:22:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |         for(int i=0; i<ans.size(); i++)
      |                      ~^~~~~~~~~~~
swaps.cpp:24:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |             for(int l=0; l<ans[i].size()-1; l+=2)
      |                          ~^~~~~~~~~~~~~~~~
swaps.cpp:35:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |         for(int i=0; i<ans.size(); i++)
      |                      ~^~~~~~~~~~~
swaps.cpp:37:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |             for(int l=0; l<ans[i].size()-1; l+=2)
      |                          ~^~~~~~~~~~~~~~~~
swaps.cpp:48:13: warning: unused variable 'k' [-Wunused-variable]
   48 |         int k=0;
      |             ^
#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...