Submission #1009883

#TimeUsernameProblemLanguageResultExecution timeMemory
1009883thangdz2k7The Collection Game (BOI21_swaps)C++17
100 / 100
4 ms1572 KiB
#include <bits/stdc++.h> #include "swaps.h" using namespace std; vector <int> ans; void solve(int n, int v){ for (int i = 1; i <= n; ++ i) ans.push_back(i); for (int t = 0; t < 9; ++ t){ for (int k = t; k >= 0; -- k){ vector <pair <int, int>> ask; for (int i = 0; i < n; ++ i){ if (((i >> k) & 1) != (k - t != 0)) continue; if (i + (1 << k) >= n) continue; if ((i + (1 << k) >> (t + 1)) != (i >> (t + 1))) continue; schedule(ans[i], ans[i + (1 << k)]); ask.push_back({i, i + (1 << k)}); } vector <int> res = visit(); for (int i = 0; i < res.size(); ++ i){ if (!res[i]) swap(ans[ask[i].first], ans[ask[i].second]); } } } answer(ans); }

Compilation message (stderr)

swaps.cpp: In function 'void solve(int, int)':
swaps.cpp:17:24: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   17 |                 if ((i + (1 << k) >> (t + 1)) != (i >> (t + 1))) continue;
      |                      ~~^~~~~~~~~~
swaps.cpp:22:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |             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...