답안 #967179

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
967179 2024-04-21T12:20:24 Z Soumya1 Minerals (JOI19_minerals) C++17
100 / 100
52 ms 4044 KB
#include "minerals.h"
#include <bits/stdc++.h>
using namespace std;
int last = 0;
bool ask(int x) {
  int nw = Query(x);
  bool g = (last != nw);
  last = nw;
  return g;
}
void solve(vector<int> a, vector<int> b, bool f) {
  if (a.size() == 1) {
    Answer(a[0], b[0]);
    return;
  }
  int n = a.size();
  int mid = (int) max(1.0, n * 0.4);
  vector<int> la, lb, ra, rb;
  random_shuffle(a.begin(), a.end());
  random_shuffle(b.begin(), b.end());
  for (int i = 0; i < n; i++) {
    if (i < mid) ask(b[i]), lb.push_back(b[i]);
    else rb.push_back(b[i]);
  }
  for (int i : a) {
    if (la.size() == mid) ra.push_back(i);
    else if (ra.size() == n - mid) la.push_back(i);
    else if (f) {
      if (ask(i)) ra.push_back(i);
      else la.push_back(i);
    } else {
      if (ask(i)) la.push_back(i);
      else ra.push_back(i);
    }
  }
  solve(la, lb, f ^ 1);
  solve(ra, rb, f);
}
void Solve(int N) {
  vector<int> a, b;
  for (int i = 1; i <= 2 * N; i++) {
    if (ask(i)) a.push_back(i);
    else b.push_back(i);
  }
  solve(a, b, 0);
}

Compilation message

minerals.cpp: In function 'void solve(std::vector<int>, std::vector<int>, bool)':
minerals.cpp:26:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   26 |     if (la.size() == mid) ra.push_back(i);
      |         ~~~~~~~~~~^~~~~~
minerals.cpp:27:24: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   27 |     else if (ra.size() == n - mid) la.push_back(i);
      |              ~~~~~~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 2 ms 600 KB Output is correct
3 Correct 4 ms 600 KB Output is correct
4 Correct 8 ms 1156 KB Output is correct
5 Correct 16 ms 1624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 2 ms 600 KB Output is correct
7 Correct 4 ms 600 KB Output is correct
8 Correct 8 ms 1156 KB Output is correct
9 Correct 16 ms 1624 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 11 ms 1240 KB Output is correct
12 Correct 18 ms 1608 KB Output is correct
13 Correct 16 ms 1564 KB Output is correct
14 Correct 16 ms 1872 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 2 ms 600 KB Output is correct
7 Correct 4 ms 600 KB Output is correct
8 Correct 8 ms 1156 KB Output is correct
9 Correct 16 ms 1624 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 11 ms 1240 KB Output is correct
12 Correct 18 ms 1608 KB Output is correct
13 Correct 16 ms 1564 KB Output is correct
14 Correct 16 ms 1872 KB Output is correct
15 Correct 47 ms 3664 KB Output is correct
16 Correct 45 ms 3480 KB Output is correct
17 Correct 44 ms 3516 KB Output is correct
18 Correct 43 ms 3436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 2 ms 600 KB Output is correct
7 Correct 4 ms 600 KB Output is correct
8 Correct 8 ms 1156 KB Output is correct
9 Correct 16 ms 1624 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 11 ms 1240 KB Output is correct
12 Correct 18 ms 1608 KB Output is correct
13 Correct 16 ms 1564 KB Output is correct
14 Correct 16 ms 1872 KB Output is correct
15 Correct 47 ms 3664 KB Output is correct
16 Correct 45 ms 3480 KB Output is correct
17 Correct 44 ms 3516 KB Output is correct
18 Correct 43 ms 3436 KB Output is correct
19 Correct 46 ms 3688 KB Output is correct
20 Correct 46 ms 3552 KB Output is correct
21 Correct 46 ms 3592 KB Output is correct
22 Correct 44 ms 3408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 2 ms 600 KB Output is correct
7 Correct 4 ms 600 KB Output is correct
8 Correct 8 ms 1156 KB Output is correct
9 Correct 16 ms 1624 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 11 ms 1240 KB Output is correct
12 Correct 18 ms 1608 KB Output is correct
13 Correct 16 ms 1564 KB Output is correct
14 Correct 16 ms 1872 KB Output is correct
15 Correct 47 ms 3664 KB Output is correct
16 Correct 45 ms 3480 KB Output is correct
17 Correct 44 ms 3516 KB Output is correct
18 Correct 43 ms 3436 KB Output is correct
19 Correct 46 ms 3688 KB Output is correct
20 Correct 46 ms 3552 KB Output is correct
21 Correct 46 ms 3592 KB Output is correct
22 Correct 44 ms 3408 KB Output is correct
23 Correct 48 ms 3820 KB Output is correct
24 Correct 48 ms 3816 KB Output is correct
25 Correct 46 ms 3692 KB Output is correct
26 Correct 46 ms 3452 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 2 ms 600 KB Output is correct
7 Correct 4 ms 600 KB Output is correct
8 Correct 8 ms 1156 KB Output is correct
9 Correct 16 ms 1624 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 11 ms 1240 KB Output is correct
12 Correct 18 ms 1608 KB Output is correct
13 Correct 16 ms 1564 KB Output is correct
14 Correct 16 ms 1872 KB Output is correct
15 Correct 47 ms 3664 KB Output is correct
16 Correct 45 ms 3480 KB Output is correct
17 Correct 44 ms 3516 KB Output is correct
18 Correct 43 ms 3436 KB Output is correct
19 Correct 46 ms 3688 KB Output is correct
20 Correct 46 ms 3552 KB Output is correct
21 Correct 46 ms 3592 KB Output is correct
22 Correct 44 ms 3408 KB Output is correct
23 Correct 48 ms 3820 KB Output is correct
24 Correct 48 ms 3816 KB Output is correct
25 Correct 46 ms 3692 KB Output is correct
26 Correct 46 ms 3452 KB Output is correct
27 Correct 49 ms 3764 KB Output is correct
28 Correct 48 ms 3812 KB Output is correct
29 Correct 48 ms 3944 KB Output is correct
30 Correct 47 ms 3800 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 2 ms 600 KB Output is correct
7 Correct 4 ms 600 KB Output is correct
8 Correct 8 ms 1156 KB Output is correct
9 Correct 16 ms 1624 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 11 ms 1240 KB Output is correct
12 Correct 18 ms 1608 KB Output is correct
13 Correct 16 ms 1564 KB Output is correct
14 Correct 16 ms 1872 KB Output is correct
15 Correct 47 ms 3664 KB Output is correct
16 Correct 45 ms 3480 KB Output is correct
17 Correct 44 ms 3516 KB Output is correct
18 Correct 43 ms 3436 KB Output is correct
19 Correct 46 ms 3688 KB Output is correct
20 Correct 46 ms 3552 KB Output is correct
21 Correct 46 ms 3592 KB Output is correct
22 Correct 44 ms 3408 KB Output is correct
23 Correct 48 ms 3820 KB Output is correct
24 Correct 48 ms 3816 KB Output is correct
25 Correct 46 ms 3692 KB Output is correct
26 Correct 46 ms 3452 KB Output is correct
27 Correct 49 ms 3764 KB Output is correct
28 Correct 48 ms 3812 KB Output is correct
29 Correct 48 ms 3944 KB Output is correct
30 Correct 47 ms 3800 KB Output is correct
31 Correct 51 ms 3888 KB Output is correct
32 Correct 51 ms 3960 KB Output is correct
33 Correct 48 ms 3804 KB Output is correct
34 Correct 48 ms 3592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 2 ms 600 KB Output is correct
7 Correct 4 ms 600 KB Output is correct
8 Correct 8 ms 1156 KB Output is correct
9 Correct 16 ms 1624 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 11 ms 1240 KB Output is correct
12 Correct 18 ms 1608 KB Output is correct
13 Correct 16 ms 1564 KB Output is correct
14 Correct 16 ms 1872 KB Output is correct
15 Correct 47 ms 3664 KB Output is correct
16 Correct 45 ms 3480 KB Output is correct
17 Correct 44 ms 3516 KB Output is correct
18 Correct 43 ms 3436 KB Output is correct
19 Correct 46 ms 3688 KB Output is correct
20 Correct 46 ms 3552 KB Output is correct
21 Correct 46 ms 3592 KB Output is correct
22 Correct 44 ms 3408 KB Output is correct
23 Correct 48 ms 3820 KB Output is correct
24 Correct 48 ms 3816 KB Output is correct
25 Correct 46 ms 3692 KB Output is correct
26 Correct 46 ms 3452 KB Output is correct
27 Correct 49 ms 3764 KB Output is correct
28 Correct 48 ms 3812 KB Output is correct
29 Correct 48 ms 3944 KB Output is correct
30 Correct 47 ms 3800 KB Output is correct
31 Correct 51 ms 3888 KB Output is correct
32 Correct 51 ms 3960 KB Output is correct
33 Correct 48 ms 3804 KB Output is correct
34 Correct 48 ms 3592 KB Output is correct
35 Correct 52 ms 3816 KB Output is correct
36 Correct 51 ms 3816 KB Output is correct
37 Correct 49 ms 4044 KB Output is correct
38 Correct 50 ms 3612 KB Output is correct