Submission #427983

#TimeUsernameProblemLanguageResultExecution timeMemory
427983patrikpavic2The Collection Game (BOI21_swaps)C++17
100 / 100
8 ms508 KiB
#include "swaps.h" #include <vector> #include <algorithm> #include <cstdio> #define X first #define Y second #define PB push_back #define EB emplace_back using namespace std; typedef vector < int > vi; typedef pair < int, int > pii; void solve(int n, int v) { int lg2 = 8; vector < int > P; vector < pii > tko; for(int i = 1;i <= n;i++) P.PB(i); for(int i = 0;i <= lg2;i++){ for(int j = i;j >= 0;j--){ for(int k = 0;k < n;k++){ if(i != j && (k & (1 << j))){ tko.EB(k ^ (1 << j), k); schedule(P[tko.back().X], P[tko.back().Y]); } if(i == j && (k ^ ((1 << (j + 1)) - 1)) < k){ tko.EB(k ^ ((1 << (j + 1)) - 1), k); schedule(P[tko.back().X], P[tko.back().Y]); } } vi odg = visit(); for(int i = 0;i < (int)odg.size();i++) if(!odg[i]) swap(P[tko[i].X], P[tko[i].Y]); tko.clear(); } } answer(P); }
#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...