Submission #402944

#TimeUsernameProblemLanguageResultExecution timeMemory
402944dooweyThe Collection Game (BOI21_swaps)C++14
100 / 100
7 ms472 KiB
#include <bits/stdc++.h> #include "swaps.h" using namespace std; typedef long long ll; typedef pair<int, int> pii; #define fi first #define se second #define mp make_pair #define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); vector<int> ord; void do_shit(vector<pii> shit){ for(auto x : shit){ schedule(ord[x.fi], ord[x.se]); } vector<int> gg = visit(); for(int i = 0 ; i < gg.size(); i ++ ){ if(!gg[i]){ swap(ord[shit[i].fi], ord[shit[i].se]); } } } void solve(int n, int q) { int nx; for(int i = 1; i <= n; i ++ ){ ord.push_back(i); } for(int k = 1; k < n * 2; k *= 2){ vector<pii> ash; for(int i = 0 ; i < n; i ++ ){ nx = (i ^ (k - 1)); if(i < nx && nx < n) ash.push_back(mp(i, nx)); } do_shit(ash); for(int v = k / 4; v > 0 ; v /= 2){ ash.clear(); for(int j = 0 ; j < n; j ++){ nx = (j ^ v); if(j < nx && nx < n){ ash.push_back(mp(j, nx)); } } do_shit(ash); } } answer(ord); }

Compilation message (stderr)

swaps.cpp: In function 'void do_shit(std::vector<std::pair<int, int> >)':
swaps.cpp:21:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |     for(int i = 0 ; i < gg.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...