답안 #797968

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
797968 2023-07-30T08:05:11 Z Oyster Minerals (JOI19_minerals) C++17
40 / 100
28 ms 2260 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]});
  N += N & 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:24:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   24 |     if (vl.size() == N || vr.size() == N)
      |         ~~~~~~~~~~^~~~
minerals.cpp:24:37: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   24 |     if (vl.size() == N || vr.size() == N)
      |                           ~~~~~~~~~~^~~~
minerals.cpp:28:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   28 |   if (vl.size() < N)
      |       ~~~~~~~~~~^~~
minerals.cpp: In function 'void Solve(int)':
minerals.cpp:40:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |   for (int i = 0; i < v.size(); i++) v[i] = i + 1;
      |                   ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 2 ms 336 KB Output is correct
3 Correct 4 ms 464 KB Output is correct
4 Correct 8 ms 700 KB Output is correct
5 Correct 16 ms 1152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 2 ms 336 KB Output is correct
7 Correct 4 ms 464 KB Output is correct
8 Correct 8 ms 700 KB Output is correct
9 Correct 16 ms 1152 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 10 ms 900 KB Output is correct
12 Correct 22 ms 1236 KB Output is correct
13 Correct 16 ms 1180 KB Output is correct
14 Correct 18 ms 1092 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 2 ms 336 KB Output is correct
7 Correct 4 ms 464 KB Output is correct
8 Correct 8 ms 700 KB Output is correct
9 Correct 16 ms 1152 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 10 ms 900 KB Output is correct
12 Correct 22 ms 1236 KB Output is correct
13 Correct 16 ms 1180 KB Output is correct
14 Correct 18 ms 1092 KB Output is correct
15 Incorrect 28 ms 2260 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 2 ms 336 KB Output is correct
7 Correct 4 ms 464 KB Output is correct
8 Correct 8 ms 700 KB Output is correct
9 Correct 16 ms 1152 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 10 ms 900 KB Output is correct
12 Correct 22 ms 1236 KB Output is correct
13 Correct 16 ms 1180 KB Output is correct
14 Correct 18 ms 1092 KB Output is correct
15 Incorrect 28 ms 2260 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 2 ms 336 KB Output is correct
7 Correct 4 ms 464 KB Output is correct
8 Correct 8 ms 700 KB Output is correct
9 Correct 16 ms 1152 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 10 ms 900 KB Output is correct
12 Correct 22 ms 1236 KB Output is correct
13 Correct 16 ms 1180 KB Output is correct
14 Correct 18 ms 1092 KB Output is correct
15 Incorrect 28 ms 2260 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 2 ms 336 KB Output is correct
7 Correct 4 ms 464 KB Output is correct
8 Correct 8 ms 700 KB Output is correct
9 Correct 16 ms 1152 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 10 ms 900 KB Output is correct
12 Correct 22 ms 1236 KB Output is correct
13 Correct 16 ms 1180 KB Output is correct
14 Correct 18 ms 1092 KB Output is correct
15 Incorrect 28 ms 2260 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 2 ms 336 KB Output is correct
7 Correct 4 ms 464 KB Output is correct
8 Correct 8 ms 700 KB Output is correct
9 Correct 16 ms 1152 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 10 ms 900 KB Output is correct
12 Correct 22 ms 1236 KB Output is correct
13 Correct 16 ms 1180 KB Output is correct
14 Correct 18 ms 1092 KB Output is correct
15 Incorrect 28 ms 2260 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 2 ms 336 KB Output is correct
7 Correct 4 ms 464 KB Output is correct
8 Correct 8 ms 700 KB Output is correct
9 Correct 16 ms 1152 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 10 ms 900 KB Output is correct
12 Correct 22 ms 1236 KB Output is correct
13 Correct 16 ms 1180 KB Output is correct
14 Correct 18 ms 1092 KB Output is correct
15 Incorrect 28 ms 2260 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -