Submission #429093

#TimeUsernameProblemLanguageResultExecution timeMemory
429093keko37The Collection Game (BOI21_swaps)C++14
100 / 100
8 ms540 KiB
#include<bits/stdc++.h> #include "swaps.h" using namespace std; typedef pair <int, int> pi; const int MAXN = 505; int n, p[MAXN]; vector <pi> v; void upd () { for (auto pp : v) schedule(p[pp.first], p[pp.second]); vector <int> ans = visit(); for (int i = 0; i < ans.size(); i++) { if (ans[i] == 0) swap(p[v[i].first], p[v[i].second]); } } void solve (int N, int V) { n = N; for (int i = 0; i < n; i++) p[i] = i + 1; for (int i = 0; i < 9; i++) { v.clear(); for (int pos = 0; pos < n; pos++) { int par = pos ^ ((1 << (i + 1)) - 1); if (par < pos) v.push_back({par, pos}); } upd(); for (int j = i - 1; j >= 0; j--) { v.clear(); for (int pos = 0; pos < n; pos++) { int par = pos ^ (1 << j); if (par < pos) v.push_back({par, pos}); } upd(); } } vector <int> sol; for (int i = 0; i < n; i++) sol.push_back(p[i]); answer(sol); }

Compilation message (stderr)

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