답안 #1042254

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1042254 2024-08-02T17:48:08 Z juicy Minerals (JOI19_minerals) C++17
100 / 100
33 ms 4432 KB
#include "minerals.h"

#include <bits/stdc++.h>

using namespace std;

template<class T>
ostream &operator << (ostream &os, vector<T> v) {
  cerr << "{";
  for (int i = 0; i < v.size(); ++i) {
    os << (i ? ", " : "") << v[i];
  }
  return os << "}";
}

void __print() {
  cerr << "]\n";
}

template<class T, class... V>
void __print(T t, V... v) {
  cerr << t;
  if (sizeof...(v)) {
    cerr << ", ";
  }
  __print(v...);
}

#ifdef LOCAL
#define debug(x...) cerr << "[" << #x << "] = ["; __print(x);
#else
#define debug(...) 42
#endif

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void dc(vector<int> A, vector<int> B, bool flg) {
  if (A.size() == 1) {
    Answer(A[0], B[0]);
    return;
  }
  int L = max(1, int(0.38 * A.size())), R = A.size() - L;
  vector<int> lA, rA, lB, rB;
  int lst = 0;
  for (int i = 0; i < L; ++i) {
    lA.push_back(A[i]);
    lst = Query(A[i]);
  }
  for (int i = L; i < A.size(); ++i) {
    rA.push_back(A[i]);
  }
  for (int x : B) {
    if (lB.size() == L) {
      rB.push_back(x);
      continue;
    } 
    if (rB.size() == R) {
      lB.push_back(x);
      continue;
    }
    int nxt = Query(x);
    if (flg ^ lst != nxt) {
      rB.push_back(x);
    } else {
      lB.push_back(x);
    }
    lst = nxt;
  }
  dc(lA, lB, flg ^ 1);
  dc(rA, rB, flg);
}

void Solve(int N) {
  vector<int> A, B, p(2 * N); iota(p.begin(), p.end(), 1);
  shuffle(p.begin(), p.end(), rng);
  for (int x : p) {
    if (A.size() != Query(x)) {
      A.push_back(x);
    } else {
      B.push_back(x);
    }
  }
  dc(A, B, 1);
}

Compilation message

minerals.cpp: In function 'void dc(std::vector<int>, std::vector<int>, bool)':
minerals.cpp:49:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |   for (int i = L; i < A.size(); ++i) {
      |                   ~~^~~~~~~~~~
minerals.cpp:53:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   53 |     if (lB.size() == L) {
      |         ~~~~~~~~~~^~~~
minerals.cpp:57:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   57 |     if (rB.size() == R) {
      |         ~~~~~~~~~~^~~~
minerals.cpp:62:19: warning: suggest parentheses around comparison in operand of '^' [-Wparentheses]
   62 |     if (flg ^ lst != nxt) {
      |               ~~~~^~~~~~
minerals.cpp: In function 'void Solve(int)':
minerals.cpp:77:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   77 |     if (A.size() != Query(x)) {
      |         ~~~~~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 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 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 2 ms 600 KB Output is correct
4 Correct 5 ms 1112 KB Output is correct
5 Correct 11 ms 1836 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 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 600 KB Output is correct
7 Correct 2 ms 600 KB Output is correct
8 Correct 5 ms 1112 KB Output is correct
9 Correct 11 ms 1836 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 6 ms 1308 KB Output is correct
12 Correct 12 ms 1768 KB Output is correct
13 Correct 10 ms 1880 KB Output is correct
14 Correct 9 ms 1620 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 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 600 KB Output is correct
7 Correct 2 ms 600 KB Output is correct
8 Correct 5 ms 1112 KB Output is correct
9 Correct 11 ms 1836 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 6 ms 1308 KB Output is correct
12 Correct 12 ms 1768 KB Output is correct
13 Correct 10 ms 1880 KB Output is correct
14 Correct 9 ms 1620 KB Output is correct
15 Correct 25 ms 3928 KB Output is correct
16 Correct 25 ms 3928 KB Output is correct
17 Correct 25 ms 3928 KB Output is correct
18 Correct 25 ms 3812 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 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 600 KB Output is correct
7 Correct 2 ms 600 KB Output is correct
8 Correct 5 ms 1112 KB Output is correct
9 Correct 11 ms 1836 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 6 ms 1308 KB Output is correct
12 Correct 12 ms 1768 KB Output is correct
13 Correct 10 ms 1880 KB Output is correct
14 Correct 9 ms 1620 KB Output is correct
15 Correct 25 ms 3928 KB Output is correct
16 Correct 25 ms 3928 KB Output is correct
17 Correct 25 ms 3928 KB Output is correct
18 Correct 25 ms 3812 KB Output is correct
19 Correct 26 ms 4108 KB Output is correct
20 Correct 25 ms 4108 KB Output is correct
21 Correct 29 ms 3956 KB Output is correct
22 Correct 25 ms 3920 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 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 600 KB Output is correct
7 Correct 2 ms 600 KB Output is correct
8 Correct 5 ms 1112 KB Output is correct
9 Correct 11 ms 1836 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 6 ms 1308 KB Output is correct
12 Correct 12 ms 1768 KB Output is correct
13 Correct 10 ms 1880 KB Output is correct
14 Correct 9 ms 1620 KB Output is correct
15 Correct 25 ms 3928 KB Output is correct
16 Correct 25 ms 3928 KB Output is correct
17 Correct 25 ms 3928 KB Output is correct
18 Correct 25 ms 3812 KB Output is correct
19 Correct 26 ms 4108 KB Output is correct
20 Correct 25 ms 4108 KB Output is correct
21 Correct 29 ms 3956 KB Output is correct
22 Correct 25 ms 3920 KB Output is correct
23 Correct 28 ms 4184 KB Output is correct
24 Correct 31 ms 4176 KB Output is correct
25 Correct 32 ms 4176 KB Output is correct
26 Correct 30 ms 3920 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 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 600 KB Output is correct
7 Correct 2 ms 600 KB Output is correct
8 Correct 5 ms 1112 KB Output is correct
9 Correct 11 ms 1836 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 6 ms 1308 KB Output is correct
12 Correct 12 ms 1768 KB Output is correct
13 Correct 10 ms 1880 KB Output is correct
14 Correct 9 ms 1620 KB Output is correct
15 Correct 25 ms 3928 KB Output is correct
16 Correct 25 ms 3928 KB Output is correct
17 Correct 25 ms 3928 KB Output is correct
18 Correct 25 ms 3812 KB Output is correct
19 Correct 26 ms 4108 KB Output is correct
20 Correct 25 ms 4108 KB Output is correct
21 Correct 29 ms 3956 KB Output is correct
22 Correct 25 ms 3920 KB Output is correct
23 Correct 28 ms 4184 KB Output is correct
24 Correct 31 ms 4176 KB Output is correct
25 Correct 32 ms 4176 KB Output is correct
26 Correct 30 ms 3920 KB Output is correct
27 Correct 28 ms 4172 KB Output is correct
28 Correct 28 ms 4240 KB Output is correct
29 Correct 27 ms 4184 KB Output is correct
30 Correct 28 ms 3920 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 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 600 KB Output is correct
7 Correct 2 ms 600 KB Output is correct
8 Correct 5 ms 1112 KB Output is correct
9 Correct 11 ms 1836 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 6 ms 1308 KB Output is correct
12 Correct 12 ms 1768 KB Output is correct
13 Correct 10 ms 1880 KB Output is correct
14 Correct 9 ms 1620 KB Output is correct
15 Correct 25 ms 3928 KB Output is correct
16 Correct 25 ms 3928 KB Output is correct
17 Correct 25 ms 3928 KB Output is correct
18 Correct 25 ms 3812 KB Output is correct
19 Correct 26 ms 4108 KB Output is correct
20 Correct 25 ms 4108 KB Output is correct
21 Correct 29 ms 3956 KB Output is correct
22 Correct 25 ms 3920 KB Output is correct
23 Correct 28 ms 4184 KB Output is correct
24 Correct 31 ms 4176 KB Output is correct
25 Correct 32 ms 4176 KB Output is correct
26 Correct 30 ms 3920 KB Output is correct
27 Correct 28 ms 4172 KB Output is correct
28 Correct 28 ms 4240 KB Output is correct
29 Correct 27 ms 4184 KB Output is correct
30 Correct 28 ms 3920 KB Output is correct
31 Correct 28 ms 4076 KB Output is correct
32 Correct 28 ms 4096 KB Output is correct
33 Correct 30 ms 4184 KB Output is correct
34 Correct 27 ms 4092 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 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 600 KB Output is correct
7 Correct 2 ms 600 KB Output is correct
8 Correct 5 ms 1112 KB Output is correct
9 Correct 11 ms 1836 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 6 ms 1308 KB Output is correct
12 Correct 12 ms 1768 KB Output is correct
13 Correct 10 ms 1880 KB Output is correct
14 Correct 9 ms 1620 KB Output is correct
15 Correct 25 ms 3928 KB Output is correct
16 Correct 25 ms 3928 KB Output is correct
17 Correct 25 ms 3928 KB Output is correct
18 Correct 25 ms 3812 KB Output is correct
19 Correct 26 ms 4108 KB Output is correct
20 Correct 25 ms 4108 KB Output is correct
21 Correct 29 ms 3956 KB Output is correct
22 Correct 25 ms 3920 KB Output is correct
23 Correct 28 ms 4184 KB Output is correct
24 Correct 31 ms 4176 KB Output is correct
25 Correct 32 ms 4176 KB Output is correct
26 Correct 30 ms 3920 KB Output is correct
27 Correct 28 ms 4172 KB Output is correct
28 Correct 28 ms 4240 KB Output is correct
29 Correct 27 ms 4184 KB Output is correct
30 Correct 28 ms 3920 KB Output is correct
31 Correct 28 ms 4076 KB Output is correct
32 Correct 28 ms 4096 KB Output is correct
33 Correct 30 ms 4184 KB Output is correct
34 Correct 27 ms 4092 KB Output is correct
35 Correct 33 ms 4176 KB Output is correct
36 Correct 29 ms 4176 KB Output is correct
37 Correct 32 ms 4432 KB Output is correct
38 Correct 30 ms 4176 KB Output is correct