Submission #857992

#TimeUsernameProblemLanguageResultExecution timeMemory
857992lovrotThe Collection Game (BOI21_swaps)C++17
0 / 100
0 ms344 KiB
#include "swaps.h" #include <cstdio> #include <algorithm> #include <vector> #define EB emplace_back #define X first #define Y second #define MP make_pair using namespace std; typedef pair<int, int> pii; void solve(int n, int v) { int log = 0, m = 1; vector<int> ANS; for(; (1 << log) < n; ++log) { m <<= 1; } for(int i = 0; i < m; ++i) ANS.EB(i < m - n ? -1 : i - m + n + 1); for(int i = 1 << 1; i <= m; i <<= 1) for(int j = i >> 1; j; j >>= 1) { vector<pii> S; for(int k = m - n; k < m; ++k) { int l = k ^ j; if(l > k) { if(k & i) swap(l, k); S.EB(MP(ANS[k], ANS[l])); schedule(ANS[k], ANS[l]); // if(k & i) S.EB(MP(ANS[l], ANS[k])); // else S.EB(MP(ANS[k], ANS[l])); } } vector<int> RES = visit(); for(int i = 0; i < RES.size(); ++i) if(!RES[i]) swap(ANS[S[i].X], ANS[S[i].Y]); S.clear(); } for(int i = 0; i < n; ++i) ANS[i] = ANS[i + m - n]; ANS.erase(ANS.begin() + n, ANS.end()); answer(ANS); }

Compilation message (stderr)

swaps.cpp: In function 'void solve(int, int)':
swaps.cpp:36:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |    for(int i = 0; i < RES.size(); ++i)
      |                   ~~^~~~~~~~~~~~
#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...