답안 #220092

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
220092 2020-04-07T00:03:32 Z rama_pang Minerals (JOI19_minerals) C++14
90 / 100
72 ms 3968 KB
#include "minerals.h"
#include <bits/stdc++.h>
using namespace std;

bool query(int x) {
  static int last = -1;
  int cur = Query(x);
  bool res = (cur == last);
  last = cur;
  return res;
}

void Solve(vector<int> A, vector<int> B, bool isBFull) {
  int n = A.size();
  if (n == 0) return;
  if (n == 1) return Answer(A[0], B[0]);

  int piv = n / 2;
  vector<int> Aleft, Aright;
  vector<int> Bleft, Bright;

  if (isBFull) { // All of B is in the box, so we remove the second half
    for (int i = piv; i < n; i++) {
      query(B[i]); // remove elements in B such that only the first half remains 
    }
  } else { // None of B is in the box, so we add the first half
    for (int i = 0; i < piv; i++) {
      query(B[i]); // add elemens in B such that only the first half remains
    }
  }

  for (int i = 0; i < n; i++) {
    if (Aright.size() == n - piv) {
      Aleft.emplace_back(A[i]);
    } else if (Aleft.size() == piv) {
      Aright.emplace_back(A[i]);
    } else if (query(A[i])) {
      Aleft.emplace_back(A[i]); // A[i] has a match is in the first half of B
    } else {
      Aright.emplace_back(A[i]); // A[i] has a match in the second half of B
    }
  }

  for (int i = 0; i < piv; i++) Bleft.emplace_back(B[i]);
  for (int i = piv; i < n; i++) Bright.emplace_back(B[i]);

  return Solve(Aleft, Bleft, true), Solve(Aright, Bright, false);
}

void Solve(int N) {
  vector<int> A, B;
  for (int i = 1; i <= 2 * N; i++) {
    if (query(i)) { // the current element is already in the box
      B.emplace_back(i);
    } else { // the current element is a new element
      A.emplace_back(i);
    }
  }

  return Solve(A, B, true);
}

Compilation message

minerals.cpp: In function 'void Solve(std::vector<int>, std::vector<int>, bool)':
minerals.cpp:33:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if (Aright.size() == n - piv) {
         ~~~~~~~~~~~~~~^~~~~~~~~~
minerals.cpp:35:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     } else if (Aleft.size() == piv) {
                ~~~~~~~~~~~~~^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 7 ms 512 KB Output is correct
3 Correct 10 ms 640 KB Output is correct
4 Correct 14 ms 1024 KB Output is correct
5 Correct 23 ms 1436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 7 ms 512 KB Output is correct
7 Correct 10 ms 640 KB Output is correct
8 Correct 14 ms 1024 KB Output is correct
9 Correct 23 ms 1436 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 17 ms 1220 KB Output is correct
12 Correct 24 ms 1576 KB Output is correct
13 Correct 21 ms 1588 KB Output is correct
14 Correct 21 ms 1448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 7 ms 512 KB Output is correct
7 Correct 10 ms 640 KB Output is correct
8 Correct 14 ms 1024 KB Output is correct
9 Correct 23 ms 1436 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 17 ms 1220 KB Output is correct
12 Correct 24 ms 1576 KB Output is correct
13 Correct 21 ms 1588 KB Output is correct
14 Correct 21 ms 1448 KB Output is correct
15 Correct 58 ms 3600 KB Output is correct
16 Correct 59 ms 3596 KB Output is correct
17 Correct 49 ms 3492 KB Output is correct
18 Correct 50 ms 3324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 7 ms 512 KB Output is correct
7 Correct 10 ms 640 KB Output is correct
8 Correct 14 ms 1024 KB Output is correct
9 Correct 23 ms 1436 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 17 ms 1220 KB Output is correct
12 Correct 24 ms 1576 KB Output is correct
13 Correct 21 ms 1588 KB Output is correct
14 Correct 21 ms 1448 KB Output is correct
15 Correct 58 ms 3600 KB Output is correct
16 Correct 59 ms 3596 KB Output is correct
17 Correct 49 ms 3492 KB Output is correct
18 Correct 50 ms 3324 KB Output is correct
19 Correct 62 ms 3592 KB Output is correct
20 Correct 67 ms 3656 KB Output is correct
21 Correct 50 ms 3536 KB Output is correct
22 Correct 50 ms 3412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 7 ms 512 KB Output is correct
7 Correct 10 ms 640 KB Output is correct
8 Correct 14 ms 1024 KB Output is correct
9 Correct 23 ms 1436 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 17 ms 1220 KB Output is correct
12 Correct 24 ms 1576 KB Output is correct
13 Correct 21 ms 1588 KB Output is correct
14 Correct 21 ms 1448 KB Output is correct
15 Correct 58 ms 3600 KB Output is correct
16 Correct 59 ms 3596 KB Output is correct
17 Correct 49 ms 3492 KB Output is correct
18 Correct 50 ms 3324 KB Output is correct
19 Correct 62 ms 3592 KB Output is correct
20 Correct 67 ms 3656 KB Output is correct
21 Correct 50 ms 3536 KB Output is correct
22 Correct 50 ms 3412 KB Output is correct
23 Correct 67 ms 3724 KB Output is correct
24 Correct 61 ms 3628 KB Output is correct
25 Correct 52 ms 3672 KB Output is correct
26 Correct 52 ms 3456 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 7 ms 512 KB Output is correct
7 Correct 10 ms 640 KB Output is correct
8 Correct 14 ms 1024 KB Output is correct
9 Correct 23 ms 1436 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 17 ms 1220 KB Output is correct
12 Correct 24 ms 1576 KB Output is correct
13 Correct 21 ms 1588 KB Output is correct
14 Correct 21 ms 1448 KB Output is correct
15 Correct 58 ms 3600 KB Output is correct
16 Correct 59 ms 3596 KB Output is correct
17 Correct 49 ms 3492 KB Output is correct
18 Correct 50 ms 3324 KB Output is correct
19 Correct 62 ms 3592 KB Output is correct
20 Correct 67 ms 3656 KB Output is correct
21 Correct 50 ms 3536 KB Output is correct
22 Correct 50 ms 3412 KB Output is correct
23 Correct 67 ms 3724 KB Output is correct
24 Correct 61 ms 3628 KB Output is correct
25 Correct 52 ms 3672 KB Output is correct
26 Correct 52 ms 3456 KB Output is correct
27 Correct 66 ms 3728 KB Output is correct
28 Correct 63 ms 3808 KB Output is correct
29 Correct 60 ms 3968 KB Output is correct
30 Correct 53 ms 3492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 7 ms 512 KB Output is correct
7 Correct 10 ms 640 KB Output is correct
8 Correct 14 ms 1024 KB Output is correct
9 Correct 23 ms 1436 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 17 ms 1220 KB Output is correct
12 Correct 24 ms 1576 KB Output is correct
13 Correct 21 ms 1588 KB Output is correct
14 Correct 21 ms 1448 KB Output is correct
15 Correct 58 ms 3600 KB Output is correct
16 Correct 59 ms 3596 KB Output is correct
17 Correct 49 ms 3492 KB Output is correct
18 Correct 50 ms 3324 KB Output is correct
19 Correct 62 ms 3592 KB Output is correct
20 Correct 67 ms 3656 KB Output is correct
21 Correct 50 ms 3536 KB Output is correct
22 Correct 50 ms 3412 KB Output is correct
23 Correct 67 ms 3724 KB Output is correct
24 Correct 61 ms 3628 KB Output is correct
25 Correct 52 ms 3672 KB Output is correct
26 Correct 52 ms 3456 KB Output is correct
27 Correct 66 ms 3728 KB Output is correct
28 Correct 63 ms 3808 KB Output is correct
29 Correct 60 ms 3968 KB Output is correct
30 Correct 53 ms 3492 KB Output is correct
31 Correct 70 ms 3916 KB Output is correct
32 Correct 65 ms 3796 KB Output is correct
33 Correct 72 ms 3812 KB Output is correct
34 Correct 61 ms 3580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 7 ms 512 KB Output is correct
7 Correct 10 ms 640 KB Output is correct
8 Correct 14 ms 1024 KB Output is correct
9 Correct 23 ms 1436 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 17 ms 1220 KB Output is correct
12 Correct 24 ms 1576 KB Output is correct
13 Correct 21 ms 1588 KB Output is correct
14 Correct 21 ms 1448 KB Output is correct
15 Correct 58 ms 3600 KB Output is correct
16 Correct 59 ms 3596 KB Output is correct
17 Correct 49 ms 3492 KB Output is correct
18 Correct 50 ms 3324 KB Output is correct
19 Correct 62 ms 3592 KB Output is correct
20 Correct 67 ms 3656 KB Output is correct
21 Correct 50 ms 3536 KB Output is correct
22 Correct 50 ms 3412 KB Output is correct
23 Correct 67 ms 3724 KB Output is correct
24 Correct 61 ms 3628 KB Output is correct
25 Correct 52 ms 3672 KB Output is correct
26 Correct 52 ms 3456 KB Output is correct
27 Correct 66 ms 3728 KB Output is correct
28 Correct 63 ms 3808 KB Output is correct
29 Correct 60 ms 3968 KB Output is correct
30 Correct 53 ms 3492 KB Output is correct
31 Correct 70 ms 3916 KB Output is correct
32 Correct 65 ms 3796 KB Output is correct
33 Correct 72 ms 3812 KB Output is correct
34 Correct 61 ms 3580 KB Output is correct
35 Incorrect 65 ms 3880 KB Wrong Answer [2]
36 Halted 0 ms 0 KB -