Submission #797962

#TimeUsernameProblemLanguageResultExecution timeMemory
797962OysterMinerals (JOI19_minerals)C++17
0 / 100
1 ms336 KiB
#include "minerals.h" #include <vector> #include <utility> #include <algorithm> #include <random> std::vector<std::pair<int, int>> ans; std::random_device rd; std::mt19937 gen(rd()); void DC(std::vector<int> &v) { int N = v.size() >> 1; if (N == 1) return ans.push_back({v[0], v[1]}); std::shuffle(v.begin(), v.end(), gen); std::vector<int> vl, vr; while (v.size()) { if (Query(v.back()) <= N >> 1) vl.push_back(v.back()); else { Query(v.back()); vr.push_back(v.back()); } v.pop_back(); if (vl.size() == N || vr.size() == N) break; } for (const int &i : vl) Query(i); if (vl.size() < N) while (v.size()) vl.push_back(v.back()), v.pop_back(); else while (v.size()) vr.push_back(v.back()), v.pop_back(); DC(vl); DC(vr); } void Solve(int N) { ans.reserve(N); std::vector<int> v(N << 1); for (int i = 0; i < v.size(); i++) v[i] = i + 1; DC(v); for (const auto &p : ans) Answer(p.first, p.second); }

Compilation message (stderr)

minerals.cpp: In function 'void DC(std::vector<int>&)':
minerals.cpp:23:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   23 |     if (vl.size() == N || vr.size() == N)
      |         ~~~~~~~~~~^~~~
minerals.cpp:23:37: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   23 |     if (vl.size() == N || vr.size() == N)
      |                           ~~~~~~~~~~^~~~
minerals.cpp:27:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   27 |   if (vl.size() < N)
      |       ~~~~~~~~~~^~~
minerals.cpp: In function 'void Solve(int)':
minerals.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 |   for (int i = 0; i < v.size(); i++) v[i] = i + 1;
      |                   ~~^~~~~~~~~~
#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...