Submission #510049

#TimeUsernameProblemLanguageResultExecution timeMemory
510049ElegiaThe Collection Game (BOI21_swaps)C++17
0 / 100
1 ms340 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 <cstdarg> #include <cstdio> #include <cstdlib> #include <set> #include <vector> #include <algorithm> #include <numeric> #include "swaps.h" using namespace std; void solve(int N, int V) { vector<vector<int>> ord; for (int i = 1; i <= N; ++i) ord.push_back({i}); for (int rep = 1; ord.size() > 1; ++rep) { vector<vector<int>> low(ord.size()), high(ord.size()); for (int i = 1; i < ord.size(); i += 2) { low[i].assign(ord[i].size(), 0); high[i].assign(ord[i].size(), ord[i - 1].size()); } for (int per = 0; per != rep; ++per) { for (int i = 1; i < ord.size(); i += 2) for (int j = 0; j != ord[i].size(); ++j) { if (low[i][j] == high[i][j]) continue; int mid = (low[i][j] + high[i][j]) / 2; schedule(ord[i - 1][mid], ord[i][j]); } vector<int> res = visit(); int cnt = 0; for (int i = 1; i < ord.size(); i += 2) for (int j = 0; j != ord[i].size(); ++j) { if (low[i][j] == high[i][j]) continue; int mid = (low[i][j] + high[i][j]) / 2; if (res[cnt++]) low[i][j] = mid + 1; else high[i][j] = mid; } } vector<vector<int>> tmp; for (int i = 1; i < ord.size(); i += 2) { vector<int> nw; nw.reserve(ord[i - 1].size() + ord[i].size()); int p = 0, q = 0; while (p < ord[i - 1].size() || q < ord[i].size()) if (q < ord[i].size() && low[i][q] <= p) nw.push_back(ord[i][q++]); else nw.push_back(ord[i - 1][p++]); tmp.push_back(nw); } if (ord.size() & 1) tmp.push_back(ord.back()); swap(ord, tmp); } answer(ord[0]); }

Compilation message (stderr)

swaps.cpp: In function 'void solve(int, int)':
swaps.cpp:26:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |   for (int i = 1; i < ord.size(); i += 2) {
      |                   ~~^~~~~~~~~~~~
swaps.cpp:31:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |    for (int i = 1; i < ord.size(); i += 2)
      |                    ~~^~~~~~~~~~~~
swaps.cpp:32:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for (int j = 0; j != ord[i].size(); ++j) {
      |                     ~~^~~~~~~~~~~~~~~~
swaps.cpp:38:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |    for (int i = 1; i < ord.size(); i += 2)
      |                    ~~^~~~~~~~~~~~
swaps.cpp:39:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     for (int j = 0; j != ord[i].size(); ++j) {
      |                     ~~^~~~~~~~~~~~~~~~
swaps.cpp:47:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |   for (int i = 1; i < ord.size(); i += 2) {
      |                   ~~^~~~~~~~~~~~
swaps.cpp:50:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |    while (p < ord[i - 1].size() || q < ord[i].size())
      |           ~~^~~~~~~~~~~~~~~~~~~
swaps.cpp:50:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |    while (p < ord[i - 1].size() || q < ord[i].size())
      |                                    ~~^~~~~~~~~~~~~~~
swaps.cpp:51:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |     if (q < ord[i].size() && low[i][q] <= p) nw.push_back(ord[i][q++]);
      |         ~~^~~~~~~~~~~~~~~
#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...