답안 #709618

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
709618 2023-03-14T03:01:43 Z null_awe Minerals (JOI19_minerals) C++14
90 / 100
53 ms 3872 KB
#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

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) {
      |         ~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 336 KB Output is correct
2 Correct 2 ms 464 KB Output is correct
3 Correct 4 ms 592 KB Output is correct
4 Correct 8 ms 908 KB Output is correct
5 Correct 15 ms 1444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 2 ms 336 KB Output is correct
6 Correct 2 ms 464 KB Output is correct
7 Correct 4 ms 592 KB Output is correct
8 Correct 8 ms 908 KB Output is correct
9 Correct 15 ms 1444 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 11 ms 1136 KB Output is correct
12 Correct 15 ms 1488 KB Output is correct
13 Correct 15 ms 1488 KB Output is correct
14 Correct 13 ms 1364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 2 ms 336 KB Output is correct
6 Correct 2 ms 464 KB Output is correct
7 Correct 4 ms 592 KB Output is correct
8 Correct 8 ms 908 KB Output is correct
9 Correct 15 ms 1444 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 11 ms 1136 KB Output is correct
12 Correct 15 ms 1488 KB Output is correct
13 Correct 15 ms 1488 KB Output is correct
14 Correct 13 ms 1364 KB Output is correct
15 Correct 46 ms 3408 KB Output is correct
16 Correct 49 ms 3392 KB Output is correct
17 Correct 35 ms 3412 KB Output is correct
18 Correct 40 ms 3344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 2 ms 336 KB Output is correct
6 Correct 2 ms 464 KB Output is correct
7 Correct 4 ms 592 KB Output is correct
8 Correct 8 ms 908 KB Output is correct
9 Correct 15 ms 1444 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 11 ms 1136 KB Output is correct
12 Correct 15 ms 1488 KB Output is correct
13 Correct 15 ms 1488 KB Output is correct
14 Correct 13 ms 1364 KB Output is correct
15 Correct 46 ms 3408 KB Output is correct
16 Correct 49 ms 3392 KB Output is correct
17 Correct 35 ms 3412 KB Output is correct
18 Correct 40 ms 3344 KB Output is correct
19 Correct 43 ms 3500 KB Output is correct
20 Correct 49 ms 3532 KB Output is correct
21 Correct 34 ms 3496 KB Output is correct
22 Correct 40 ms 3472 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 2 ms 336 KB Output is correct
6 Correct 2 ms 464 KB Output is correct
7 Correct 4 ms 592 KB Output is correct
8 Correct 8 ms 908 KB Output is correct
9 Correct 15 ms 1444 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 11 ms 1136 KB Output is correct
12 Correct 15 ms 1488 KB Output is correct
13 Correct 15 ms 1488 KB Output is correct
14 Correct 13 ms 1364 KB Output is correct
15 Correct 46 ms 3408 KB Output is correct
16 Correct 49 ms 3392 KB Output is correct
17 Correct 35 ms 3412 KB Output is correct
18 Correct 40 ms 3344 KB Output is correct
19 Correct 43 ms 3500 KB Output is correct
20 Correct 49 ms 3532 KB Output is correct
21 Correct 34 ms 3496 KB Output is correct
22 Correct 40 ms 3472 KB Output is correct
23 Correct 53 ms 3572 KB Output is correct
24 Correct 47 ms 3592 KB Output is correct
25 Correct 36 ms 3556 KB Output is correct
26 Correct 36 ms 3460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 2 ms 336 KB Output is correct
6 Correct 2 ms 464 KB Output is correct
7 Correct 4 ms 592 KB Output is correct
8 Correct 8 ms 908 KB Output is correct
9 Correct 15 ms 1444 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 11 ms 1136 KB Output is correct
12 Correct 15 ms 1488 KB Output is correct
13 Correct 15 ms 1488 KB Output is correct
14 Correct 13 ms 1364 KB Output is correct
15 Correct 46 ms 3408 KB Output is correct
16 Correct 49 ms 3392 KB Output is correct
17 Correct 35 ms 3412 KB Output is correct
18 Correct 40 ms 3344 KB Output is correct
19 Correct 43 ms 3500 KB Output is correct
20 Correct 49 ms 3532 KB Output is correct
21 Correct 34 ms 3496 KB Output is correct
22 Correct 40 ms 3472 KB Output is correct
23 Correct 53 ms 3572 KB Output is correct
24 Correct 47 ms 3592 KB Output is correct
25 Correct 36 ms 3556 KB Output is correct
26 Correct 36 ms 3460 KB Output is correct
27 Correct 43 ms 3624 KB Output is correct
28 Correct 43 ms 3704 KB Output is correct
29 Correct 36 ms 3684 KB Output is correct
30 Correct 45 ms 3532 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 2 ms 336 KB Output is correct
6 Correct 2 ms 464 KB Output is correct
7 Correct 4 ms 592 KB Output is correct
8 Correct 8 ms 908 KB Output is correct
9 Correct 15 ms 1444 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 11 ms 1136 KB Output is correct
12 Correct 15 ms 1488 KB Output is correct
13 Correct 15 ms 1488 KB Output is correct
14 Correct 13 ms 1364 KB Output is correct
15 Correct 46 ms 3408 KB Output is correct
16 Correct 49 ms 3392 KB Output is correct
17 Correct 35 ms 3412 KB Output is correct
18 Correct 40 ms 3344 KB Output is correct
19 Correct 43 ms 3500 KB Output is correct
20 Correct 49 ms 3532 KB Output is correct
21 Correct 34 ms 3496 KB Output is correct
22 Correct 40 ms 3472 KB Output is correct
23 Correct 53 ms 3572 KB Output is correct
24 Correct 47 ms 3592 KB Output is correct
25 Correct 36 ms 3556 KB Output is correct
26 Correct 36 ms 3460 KB Output is correct
27 Correct 43 ms 3624 KB Output is correct
28 Correct 43 ms 3704 KB Output is correct
29 Correct 36 ms 3684 KB Output is correct
30 Correct 45 ms 3532 KB Output is correct
31 Correct 52 ms 3780 KB Output is correct
32 Correct 44 ms 3688 KB Output is correct
33 Correct 38 ms 3692 KB Output is correct
34 Correct 45 ms 3536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 2 ms 336 KB Output is correct
6 Correct 2 ms 464 KB Output is correct
7 Correct 4 ms 592 KB Output is correct
8 Correct 8 ms 908 KB Output is correct
9 Correct 15 ms 1444 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 11 ms 1136 KB Output is correct
12 Correct 15 ms 1488 KB Output is correct
13 Correct 15 ms 1488 KB Output is correct
14 Correct 13 ms 1364 KB Output is correct
15 Correct 46 ms 3408 KB Output is correct
16 Correct 49 ms 3392 KB Output is correct
17 Correct 35 ms 3412 KB Output is correct
18 Correct 40 ms 3344 KB Output is correct
19 Correct 43 ms 3500 KB Output is correct
20 Correct 49 ms 3532 KB Output is correct
21 Correct 34 ms 3496 KB Output is correct
22 Correct 40 ms 3472 KB Output is correct
23 Correct 53 ms 3572 KB Output is correct
24 Correct 47 ms 3592 KB Output is correct
25 Correct 36 ms 3556 KB Output is correct
26 Correct 36 ms 3460 KB Output is correct
27 Correct 43 ms 3624 KB Output is correct
28 Correct 43 ms 3704 KB Output is correct
29 Correct 36 ms 3684 KB Output is correct
30 Correct 45 ms 3532 KB Output is correct
31 Correct 52 ms 3780 KB Output is correct
32 Correct 44 ms 3688 KB Output is correct
33 Correct 38 ms 3692 KB Output is correct
34 Correct 45 ms 3536 KB Output is correct
35 Incorrect 43 ms 3872 KB Wrong Answer [2]
36 Halted 0 ms 0 KB -