Submission #820005

#TimeUsernameProblemLanguageResultExecution timeMemory
820005MohamedAhmed04The Collection Game (BOI21_swaps)C++14
0 / 100
1 ms208 KiB
#include <bits/stdc++.h> #include "swaps.h" using namespace std ; int n ; vector<int>solve() { vector< vector<int> >v ; for(int i = 1 ; i <= n ; ++i) v.push_back({i}) ; while(v.size() > 1) { vector< vector<int> >v2 ; int sz = v.size() ; vector< array<int , 4> >state ; for(int i = 0 ; i < sz-1 ; i += 2) { state.push_back({i , i+1 , 0 , 0}) ; v2.push_back({}) ; } if((sz & 1)) v2.push_back(v[sz-1]) ; bool ok = false ; while(!ok) { for(auto &a : state) { if(a[2] < v[a[0]].size() && a[3] < v[a[1]].size()) schedule(v[a[0]][a[2]] , v[a[1]][a[3]]) ; else if(a[2] < v[a[0]].size() && a[3] == v[a[1]].size()) schedule(v[a[0]][a[2]] , v[a[0]][a[2]+1]) ; else if(a[2] == v[a[0]].size() && a[3] < v[a[1]].size()) schedule(v[a[1]][a[3]] , v[a[1]][a[3]+1]) ; } vector<int>cur = visit() ; int idx = 0 ; for(auto &a : state) { int idx2 = a[0] / 2 ; if(a[2] < v[a[0]].size() && a[3] < v[a[1]].size()) { if(cur[idx]) v2[idx2].push_back(v[a[0]][a[2]]) , a[2]++ ; else v2[idx2].push_back(v[a[1]][a[3]]) , a[3]++ ; if(a[2] == v[a[0]].size() && a[3] == (int)(v[a[1]].size()) - 1) v2[idx2].push_back(v[a[1]][a[3]]) , a[3]++ ; else if(a[3] == v[a[1]].size() && a[2] == (int)(v[a[0]].size()) - 1) v2[idx2].push_back(v[a[0]][a[2]]) , a[2]++ ; ++idx ; } else if(a[2] < v[a[0]].size() && a[3] == v[a[1]].size()) { if(cur[idx]) v2[idx2].push_back(v[a[0]][a[2]]) ; else v2[idx2].push_back(v[a[0]][a[2]+1]) ; a[2]++ ; if(a[2] == (int)(v[a[0]].size()) - 1) v2[idx2].push_back(v[a[0]][a[2]]) , a[2]++ ; } else if(a[2] == v[a[0]].size() && a[3] < v[a[1]].size()) { if(cur[idx]) v2[idx2].push_back(v[a[1]][a[3]]) ; else v2[idx2].push_back(v[a[1]][a[3]+1]) ; a[3]++ ; if(a[3] == (int)(v[a[1]].size()) - 1) v2[idx2].push_back(v[a[1]][a[3]]) , a[3]++ ; } } ok = true ; for(auto &a : state) ok &= (a[2] == v[a[0]].size() && a[3] == v[a[1]].size()) ; } v = v2 ; } return v[0] ; } void solve(int N, int V) { n = N ; answer(solve()) ; return ; }

Compilation message (stderr)

swaps.cpp: In function 'std::vector<int> solve()':
swaps.cpp:30:13: warning: comparison of integer expressions of different signedness: 'std::array<int, 4>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     if(a[2] < v[a[0]].size() && a[3] < v[a[1]].size())
swaps.cpp:30:38: warning: comparison of integer expressions of different signedness: 'std::array<int, 4>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     if(a[2] < v[a[0]].size() && a[3] < v[a[1]].size())
swaps.cpp:32:18: warning: comparison of integer expressions of different signedness: 'std::array<int, 4>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     else if(a[2] < v[a[0]].size() && a[3] == v[a[1]].size())
swaps.cpp:32:43: warning: comparison of integer expressions of different signedness: 'std::array<int, 4>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     else if(a[2] < v[a[0]].size() && a[3] == v[a[1]].size())
swaps.cpp:34:18: warning: comparison of integer expressions of different signedness: 'std::array<int, 4>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     else if(a[2] == v[a[0]].size() && a[3] < v[a[1]].size())
swaps.cpp:34:44: warning: comparison of integer expressions of different signedness: 'std::array<int, 4>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     else if(a[2] == v[a[0]].size() && a[3] < v[a[1]].size())
swaps.cpp:42:13: warning: comparison of integer expressions of different signedness: 'std::array<int, 4>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |     if(a[2] < v[a[0]].size() && a[3] < v[a[1]].size())
swaps.cpp:42:38: warning: comparison of integer expressions of different signedness: 'std::array<int, 4>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |     if(a[2] < v[a[0]].size() && a[3] < v[a[1]].size())
swaps.cpp:48:14: warning: comparison of integer expressions of different signedness: 'std::array<int, 4>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |      if(a[2] == v[a[0]].size() && a[3] == (int)(v[a[1]].size()) - 1)
swaps.cpp:50:19: warning: comparison of integer expressions of different signedness: 'std::array<int, 4>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |      else if(a[3] == v[a[1]].size() && a[2] == (int)(v[a[0]].size()) - 1)
swaps.cpp:54:18: warning: comparison of integer expressions of different signedness: 'std::array<int, 4>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |     else if(a[2] < v[a[0]].size() && a[3] == v[a[1]].size())
swaps.cpp:54:43: warning: comparison of integer expressions of different signedness: 'std::array<int, 4>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |     else if(a[2] < v[a[0]].size() && a[3] == v[a[1]].size())
swaps.cpp:64:18: warning: comparison of integer expressions of different signedness: 'std::array<int, 4>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |     else if(a[2] == v[a[0]].size() && a[3] < v[a[1]].size())
swaps.cpp:64:44: warning: comparison of integer expressions of different signedness: 'std::array<int, 4>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |     else if(a[2] == v[a[0]].size() && a[3] < v[a[1]].size())
swaps.cpp:77:17: warning: comparison of integer expressions of different signedness: 'std::array<int, 4>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   77 |     ok &= (a[2] == v[a[0]].size() && a[3] == v[a[1]].size()) ;
swaps.cpp:77:43: warning: comparison of integer expressions of different signedness: 'std::array<int, 4>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   77 |     ok &= (a[2] == v[a[0]].size() && a[3] == v[a[1]].size()) ;
#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...