Submission #709618

#TimeUsernameProblemLanguageResultExecution timeMemory
709618null_aweMinerals (JOI19_minerals)C++14
90 / 100
53 ms3872 KiB
#include <iostream> #include <vector> #include <set> #include <algorithm> #include <random> #include "minerals.h" using namespace std; vector<bool> on; int ans; void solve(vector<int> a, vector<int> b) { if (a.size() == 1) { Answer(a[0], b[0]); return; } int n = a.size() / 2, m = a.size() - n; vector<int> a1, a2; vector<int> b1, b2; for (int i : a) { if (on[i] && a1.size() < n) a1.push_back(i); else if (on[i]) a2.push_back(i); if (!on[i] && a2.size() < m) a2.push_back(i); else if (!on[i]) a1.push_back(i); } for (int i : a1) if (!on[i]) ans = Query(i), on[i] = 1; for (int i : a2) if (on[i]) ans = Query(i), on[i] = 0; for (int i : b) { if (b1.size() == n) { b2.push_back(i); continue; } if (b2.size() == m) { b1.push_back(i); continue; } int now = Query(i); if (now == ans) b1.push_back(i); else b2.push_back(i); ans = now; } solve(a1, b1), solve(a2, b2); } void Solve(int n) { on.resize(2 * n + 1); vector<int> a, b; int last = 0; for (int i = 1; i <= 2 * n; ++i) { int now = Query(i); if (now > last) a.push_back(i), on[i] = 1; else b.push_back(i); last = ans = now; } solve(a, b); }

Compilation message (stderr)

minerals.cpp: In function 'void solve(std::vector<int>, std::vector<int>)':
minerals.cpp:21:28: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   21 |     if (on[i] && a1.size() < n) a1.push_back(i);
      |                  ~~~~~~~~~~^~~
minerals.cpp:23:29: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   23 |     if (!on[i] && a2.size() < m) a2.push_back(i);
      |                   ~~~~~~~~~~^~~
minerals.cpp:29:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   29 |     if (b1.size() == n) {
      |         ~~~~~~~~~~^~~~
minerals.cpp:33:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   33 |     if (b2.size() == m) {
      |         ~~~~~~~~~~^~~~
#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...