Submission #1050182

#TimeUsernameProblemLanguageResultExecution timeMemory
1050182shiomusubi496The Collection Game (BOI21_swaps)C++17
15 / 100
32 ms1440 KiB
// // --- Sample implementation for the task swaps --- // // To compile this program with the sample grader, place: // swaps.h swaps_sample.cpp sample_grader.cpp // in a single folder and run: // g++ swaps_sample.cpp sample_grader.cpp // in this folder. // #include "swaps.h" #include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define rep2(i, a, b) for (int i = (int)(a); i < (int)(b); ++i) #define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i) #define rrep2(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); --i) #define all(v) begin(v), end(v) #define rall(v) rbegin(v), rend(v) using namespace std; using ll = long long; template<class T, class U> bool chmin(T& a, const U& b) { return a > b ? a = b, true : false; } template<class T, class U> bool chmax(T& a, const U& b) { return a < b ? a = b, true : false; } mt19937 mt(random_device{}()); void solve(int N, int V) { vector<vector<int>> g(N); rep2 (k, 1, N) { rep (i, N) { if (i / k % 2 == 1) continue; if (i + k < N) schedule(i + 1, i + k + 1); } auto res = visit(); int cnt = 0; rep (i, N) { if (cnt == res.size()) break; if (i / k % 2 == 1) continue; if (res[cnt++]) g[i].push_back(i + k); else g[i + k].push_back(i); } rep (i, N) { if (i / k % 2 == 0) continue; if (i + k < N) schedule(i + 1, i + k + 1); } res = visit(); cnt = 0; rep (i, N) { if (cnt == res.size()) break; if (i / k % 2 == 0) continue; if (res[cnt++]) g[i].push_back(i + k); else g[i + k].push_back(i); } } vector<int> tps; { vector<bool> used(N); vector<int> ord; auto dfs = [&](auto&& self, int v) -> void { used[v] = true; for (int u : g[v]) if (!used[u]) self(self, u); ord.push_back(v); }; rep (v, N) if (!used[v]) dfs(dfs, v); reverse(all(ord)); tps = ord; } rep (i, N) ++tps[i]; answer(tps); }

Compilation message (stderr)

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