답안 #709611

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
709611 2023-03-14T02:30:55 Z null_awe Minerals (JOI19_minerals) C++14
90 / 100
138 ms 262144 KB
#include <iostream>
#include <vector>
#include <set>
#include "minerals.h"
using namespace std;

set<int> on;
int ans;
int N;

void solve(vector<int> a, vector<int> b) {
  if (a.size() == 1) {
    if (N <= 42000) Answer(a[0], b[0]);
    return;
  }
  int n = a.size() / 2, m = a.size() - n;
  vector<int> a1(n), a2(m);
  vector<int> b1, b2;
  for (int i = 0; i < n; ++i) a1[i] = a[i];
  for (int i = 0; i < m; ++i) a2[i] = a[i + n];
  for (int i : a1) if (!on.count(i)) ans = Query(i), on.insert(i);
  for (int i : a2) if (on.count(i)) ans = Query(i), on.erase(i);
  for (int i : b) {
    if (b1.size() == n) {
      b2.push_back(i);
      continue;
    } else 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) {
  N = n;
  vector<int> a, b;
  int last = 0;
  if (N <= 42000) {
  for (int i = 1; i <= 2 * n; ++i) {
    int now = Query(i);
    ans = now;
    if (now > last) a.push_back(i), on.insert(i);
    else b.push_back(i);
    last = now;
  }
  }
  solve(a, b);
}

Compilation message

minerals.cpp: In function 'void solve(std::vector<int>, 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 (b1.size() == n) {
      |         ~~~~~~~~~~^~~~
minerals.cpp:27:26: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   27 |     } else 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 1 ms 384 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 3 ms 464 KB Output is correct
3 Correct 7 ms 720 KB Output is correct
4 Correct 14 ms 1008 KB Output is correct
5 Correct 31 ms 1816 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 1 ms 384 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 2 ms 336 KB Output is correct
6 Correct 3 ms 464 KB Output is correct
7 Correct 7 ms 720 KB Output is correct
8 Correct 14 ms 1008 KB Output is correct
9 Correct 31 ms 1816 KB Output is correct
10 Correct 2 ms 336 KB Output is correct
11 Correct 20 ms 1408 KB Output is correct
12 Correct 34 ms 1824 KB Output is correct
13 Correct 28 ms 1872 KB Output is correct
14 Correct 30 ms 1776 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 1 ms 384 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 2 ms 336 KB Output is correct
6 Correct 3 ms 464 KB Output is correct
7 Correct 7 ms 720 KB Output is correct
8 Correct 14 ms 1008 KB Output is correct
9 Correct 31 ms 1816 KB Output is correct
10 Correct 2 ms 336 KB Output is correct
11 Correct 20 ms 1408 KB Output is correct
12 Correct 34 ms 1824 KB Output is correct
13 Correct 28 ms 1872 KB Output is correct
14 Correct 30 ms 1776 KB Output is correct
15 Correct 88 ms 4392 KB Output is correct
16 Correct 93 ms 4408 KB Output is correct
17 Correct 99 ms 4464 KB Output is correct
18 Correct 84 ms 4300 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 1 ms 384 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 2 ms 336 KB Output is correct
6 Correct 3 ms 464 KB Output is correct
7 Correct 7 ms 720 KB Output is correct
8 Correct 14 ms 1008 KB Output is correct
9 Correct 31 ms 1816 KB Output is correct
10 Correct 2 ms 336 KB Output is correct
11 Correct 20 ms 1408 KB Output is correct
12 Correct 34 ms 1824 KB Output is correct
13 Correct 28 ms 1872 KB Output is correct
14 Correct 30 ms 1776 KB Output is correct
15 Correct 88 ms 4392 KB Output is correct
16 Correct 93 ms 4408 KB Output is correct
17 Correct 99 ms 4464 KB Output is correct
18 Correct 84 ms 4300 KB Output is correct
19 Correct 88 ms 4548 KB Output is correct
20 Correct 89 ms 4512 KB Output is correct
21 Correct 87 ms 4572 KB Output is correct
22 Correct 97 ms 4340 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 1 ms 384 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 2 ms 336 KB Output is correct
6 Correct 3 ms 464 KB Output is correct
7 Correct 7 ms 720 KB Output is correct
8 Correct 14 ms 1008 KB Output is correct
9 Correct 31 ms 1816 KB Output is correct
10 Correct 2 ms 336 KB Output is correct
11 Correct 20 ms 1408 KB Output is correct
12 Correct 34 ms 1824 KB Output is correct
13 Correct 28 ms 1872 KB Output is correct
14 Correct 30 ms 1776 KB Output is correct
15 Correct 88 ms 4392 KB Output is correct
16 Correct 93 ms 4408 KB Output is correct
17 Correct 99 ms 4464 KB Output is correct
18 Correct 84 ms 4300 KB Output is correct
19 Correct 88 ms 4548 KB Output is correct
20 Correct 89 ms 4512 KB Output is correct
21 Correct 87 ms 4572 KB Output is correct
22 Correct 97 ms 4340 KB Output is correct
23 Correct 105 ms 4620 KB Output is correct
24 Correct 93 ms 4780 KB Output is correct
25 Correct 87 ms 4632 KB Output is correct
26 Correct 87 ms 4552 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 1 ms 384 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 2 ms 336 KB Output is correct
6 Correct 3 ms 464 KB Output is correct
7 Correct 7 ms 720 KB Output is correct
8 Correct 14 ms 1008 KB Output is correct
9 Correct 31 ms 1816 KB Output is correct
10 Correct 2 ms 336 KB Output is correct
11 Correct 20 ms 1408 KB Output is correct
12 Correct 34 ms 1824 KB Output is correct
13 Correct 28 ms 1872 KB Output is correct
14 Correct 30 ms 1776 KB Output is correct
15 Correct 88 ms 4392 KB Output is correct
16 Correct 93 ms 4408 KB Output is correct
17 Correct 99 ms 4464 KB Output is correct
18 Correct 84 ms 4300 KB Output is correct
19 Correct 88 ms 4548 KB Output is correct
20 Correct 89 ms 4512 KB Output is correct
21 Correct 87 ms 4572 KB Output is correct
22 Correct 97 ms 4340 KB Output is correct
23 Correct 105 ms 4620 KB Output is correct
24 Correct 93 ms 4780 KB Output is correct
25 Correct 87 ms 4632 KB Output is correct
26 Correct 87 ms 4552 KB Output is correct
27 Correct 119 ms 4740 KB Output is correct
28 Correct 95 ms 4804 KB Output is correct
29 Correct 88 ms 4840 KB Output is correct
30 Correct 88 ms 4632 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 1 ms 384 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 2 ms 336 KB Output is correct
6 Correct 3 ms 464 KB Output is correct
7 Correct 7 ms 720 KB Output is correct
8 Correct 14 ms 1008 KB Output is correct
9 Correct 31 ms 1816 KB Output is correct
10 Correct 2 ms 336 KB Output is correct
11 Correct 20 ms 1408 KB Output is correct
12 Correct 34 ms 1824 KB Output is correct
13 Correct 28 ms 1872 KB Output is correct
14 Correct 30 ms 1776 KB Output is correct
15 Correct 88 ms 4392 KB Output is correct
16 Correct 93 ms 4408 KB Output is correct
17 Correct 99 ms 4464 KB Output is correct
18 Correct 84 ms 4300 KB Output is correct
19 Correct 88 ms 4548 KB Output is correct
20 Correct 89 ms 4512 KB Output is correct
21 Correct 87 ms 4572 KB Output is correct
22 Correct 97 ms 4340 KB Output is correct
23 Correct 105 ms 4620 KB Output is correct
24 Correct 93 ms 4780 KB Output is correct
25 Correct 87 ms 4632 KB Output is correct
26 Correct 87 ms 4552 KB Output is correct
27 Correct 119 ms 4740 KB Output is correct
28 Correct 95 ms 4804 KB Output is correct
29 Correct 88 ms 4840 KB Output is correct
30 Correct 88 ms 4632 KB Output is correct
31 Correct 127 ms 4840 KB Output is correct
32 Correct 99 ms 4972 KB Output is correct
33 Correct 91 ms 4872 KB Output is correct
34 Correct 92 ms 4844 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 1 ms 384 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 2 ms 336 KB Output is correct
6 Correct 3 ms 464 KB Output is correct
7 Correct 7 ms 720 KB Output is correct
8 Correct 14 ms 1008 KB Output is correct
9 Correct 31 ms 1816 KB Output is correct
10 Correct 2 ms 336 KB Output is correct
11 Correct 20 ms 1408 KB Output is correct
12 Correct 34 ms 1824 KB Output is correct
13 Correct 28 ms 1872 KB Output is correct
14 Correct 30 ms 1776 KB Output is correct
15 Correct 88 ms 4392 KB Output is correct
16 Correct 93 ms 4408 KB Output is correct
17 Correct 99 ms 4464 KB Output is correct
18 Correct 84 ms 4300 KB Output is correct
19 Correct 88 ms 4548 KB Output is correct
20 Correct 89 ms 4512 KB Output is correct
21 Correct 87 ms 4572 KB Output is correct
22 Correct 97 ms 4340 KB Output is correct
23 Correct 105 ms 4620 KB Output is correct
24 Correct 93 ms 4780 KB Output is correct
25 Correct 87 ms 4632 KB Output is correct
26 Correct 87 ms 4552 KB Output is correct
27 Correct 119 ms 4740 KB Output is correct
28 Correct 95 ms 4804 KB Output is correct
29 Correct 88 ms 4840 KB Output is correct
30 Correct 88 ms 4632 KB Output is correct
31 Correct 127 ms 4840 KB Output is correct
32 Correct 99 ms 4972 KB Output is correct
33 Correct 91 ms 4872 KB Output is correct
34 Correct 92 ms 4844 KB Output is correct
35 Runtime error 138 ms 262144 KB Execution killed with signal 9
36 Halted 0 ms 0 KB -