Submission #797962

# Submission time Handle Problem Language Result Execution time Memory
797962 2023-07-30T08:00:21 Z Oyster Minerals (JOI19_minerals) C++17
0 / 100
1 ms 336 KB
#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

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 time Memory Grader output
1 Incorrect 0 ms 208 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -