답안 #378189

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
378189 2021-03-16T07:10:30 Z 2qbingxuan Minerals (JOI19_minerals) C++14
100 / 100
61 ms 3564 KB
#include "minerals.h"
#include <bits/stdc++.h>
using namespace std;

const double e = exp(1);
 
int cur = 0;
void dq(vector<int> A, vector<int> B, bool flag) {
    assert(A.size() == B.size());
    if (A.empty()) return;
    if (A.size() == 1) {
        // cerr << "cand.size() = " << cand.size() << endl;
        Answer(A[0], B[0]);
        return;
    }
    int m = max<int>(1,  A.size() / e);
    for (int i = 0; i < m; i++)
        cur = Query(A[i]);
    vector<int> L, R;
    for (int x: B) {
        if (L.size() == m) {
            R.push_back(x);
            continue;
        }
        if (R.size() == A.size() - m) {
            L.push_back(x);
            continue;
        }
        int now = Query(x);
        if ((now == cur) ^ flag) {
            L.push_back(x);
        } else {
            R.push_back(x);
        }
        cur = now;
    }
    dq(vector<int>(A.begin(), A.begin() + m), L, !flag);
    dq(vector<int>(A.begin() + m, A.end()), R, flag);
}
void Solve(int N) {
    vector<int> A, B;
    int cur = 0;
    for (int i = 1; i <= N*2; i++) {
        int q = Query(i);
        if (q == cur) {
            A.push_back(i);
        } else {
            B.push_back(i);
        }
        cur = q;
    }
    dq(A, B, true);
    // for (int i = 1; i <= 50; i++) cerr << i << ' ' << f(i) << endl;
    /*
    for (int i = 1; i <= N*2; i++) {
        Query(i);
        for (int j = 1; j < i; j++) {
            if (Query(j) == 1)
                Answer(i, j);
            Query(j);
        }
        Query(i);
    }
    */
}

Compilation message

minerals.cpp: In function 'void dq(std::vector<int>, std::vector<int>, bool)':
minerals.cpp:21:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   21 |         if (L.size() == m) {
      |             ~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 2 ms 492 KB Output is correct
3 Correct 4 ms 620 KB Output is correct
4 Correct 8 ms 876 KB Output is correct
5 Correct 16 ms 1516 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 2 ms 492 KB Output is correct
7 Correct 4 ms 620 KB Output is correct
8 Correct 8 ms 876 KB Output is correct
9 Correct 16 ms 1516 KB Output is correct
10 Correct 2 ms 364 KB Output is correct
11 Correct 10 ms 1132 KB Output is correct
12 Correct 20 ms 1516 KB Output is correct
13 Correct 15 ms 1516 KB Output is correct
14 Correct 16 ms 1388 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 2 ms 492 KB Output is correct
7 Correct 4 ms 620 KB Output is correct
8 Correct 8 ms 876 KB Output is correct
9 Correct 16 ms 1516 KB Output is correct
10 Correct 2 ms 364 KB Output is correct
11 Correct 10 ms 1132 KB Output is correct
12 Correct 20 ms 1516 KB Output is correct
13 Correct 15 ms 1516 KB Output is correct
14 Correct 16 ms 1388 KB Output is correct
15 Correct 39 ms 3180 KB Output is correct
16 Correct 40 ms 3236 KB Output is correct
17 Correct 29 ms 3176 KB Output is correct
18 Correct 35 ms 3272 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 2 ms 492 KB Output is correct
7 Correct 4 ms 620 KB Output is correct
8 Correct 8 ms 876 KB Output is correct
9 Correct 16 ms 1516 KB Output is correct
10 Correct 2 ms 364 KB Output is correct
11 Correct 10 ms 1132 KB Output is correct
12 Correct 20 ms 1516 KB Output is correct
13 Correct 15 ms 1516 KB Output is correct
14 Correct 16 ms 1388 KB Output is correct
15 Correct 39 ms 3180 KB Output is correct
16 Correct 40 ms 3236 KB Output is correct
17 Correct 29 ms 3176 KB Output is correct
18 Correct 35 ms 3272 KB Output is correct
19 Correct 46 ms 3180 KB Output is correct
20 Correct 40 ms 3180 KB Output is correct
21 Correct 29 ms 3176 KB Output is correct
22 Correct 36 ms 3052 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 2 ms 492 KB Output is correct
7 Correct 4 ms 620 KB Output is correct
8 Correct 8 ms 876 KB Output is correct
9 Correct 16 ms 1516 KB Output is correct
10 Correct 2 ms 364 KB Output is correct
11 Correct 10 ms 1132 KB Output is correct
12 Correct 20 ms 1516 KB Output is correct
13 Correct 15 ms 1516 KB Output is correct
14 Correct 16 ms 1388 KB Output is correct
15 Correct 39 ms 3180 KB Output is correct
16 Correct 40 ms 3236 KB Output is correct
17 Correct 29 ms 3176 KB Output is correct
18 Correct 35 ms 3272 KB Output is correct
19 Correct 46 ms 3180 KB Output is correct
20 Correct 40 ms 3180 KB Output is correct
21 Correct 29 ms 3176 KB Output is correct
22 Correct 36 ms 3052 KB Output is correct
23 Correct 42 ms 3308 KB Output is correct
24 Correct 43 ms 3308 KB Output is correct
25 Correct 32 ms 3304 KB Output is correct
26 Correct 36 ms 3308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 2 ms 492 KB Output is correct
7 Correct 4 ms 620 KB Output is correct
8 Correct 8 ms 876 KB Output is correct
9 Correct 16 ms 1516 KB Output is correct
10 Correct 2 ms 364 KB Output is correct
11 Correct 10 ms 1132 KB Output is correct
12 Correct 20 ms 1516 KB Output is correct
13 Correct 15 ms 1516 KB Output is correct
14 Correct 16 ms 1388 KB Output is correct
15 Correct 39 ms 3180 KB Output is correct
16 Correct 40 ms 3236 KB Output is correct
17 Correct 29 ms 3176 KB Output is correct
18 Correct 35 ms 3272 KB Output is correct
19 Correct 46 ms 3180 KB Output is correct
20 Correct 40 ms 3180 KB Output is correct
21 Correct 29 ms 3176 KB Output is correct
22 Correct 36 ms 3052 KB Output is correct
23 Correct 42 ms 3308 KB Output is correct
24 Correct 43 ms 3308 KB Output is correct
25 Correct 32 ms 3304 KB Output is correct
26 Correct 36 ms 3308 KB Output is correct
27 Correct 48 ms 3308 KB Output is correct
28 Correct 48 ms 3308 KB Output is correct
29 Correct 32 ms 3336 KB Output is correct
30 Correct 33 ms 3180 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 2 ms 492 KB Output is correct
7 Correct 4 ms 620 KB Output is correct
8 Correct 8 ms 876 KB Output is correct
9 Correct 16 ms 1516 KB Output is correct
10 Correct 2 ms 364 KB Output is correct
11 Correct 10 ms 1132 KB Output is correct
12 Correct 20 ms 1516 KB Output is correct
13 Correct 15 ms 1516 KB Output is correct
14 Correct 16 ms 1388 KB Output is correct
15 Correct 39 ms 3180 KB Output is correct
16 Correct 40 ms 3236 KB Output is correct
17 Correct 29 ms 3176 KB Output is correct
18 Correct 35 ms 3272 KB Output is correct
19 Correct 46 ms 3180 KB Output is correct
20 Correct 40 ms 3180 KB Output is correct
21 Correct 29 ms 3176 KB Output is correct
22 Correct 36 ms 3052 KB Output is correct
23 Correct 42 ms 3308 KB Output is correct
24 Correct 43 ms 3308 KB Output is correct
25 Correct 32 ms 3304 KB Output is correct
26 Correct 36 ms 3308 KB Output is correct
27 Correct 48 ms 3308 KB Output is correct
28 Correct 48 ms 3308 KB Output is correct
29 Correct 32 ms 3336 KB Output is correct
30 Correct 33 ms 3180 KB Output is correct
31 Correct 61 ms 3436 KB Output is correct
32 Correct 45 ms 3436 KB Output is correct
33 Correct 32 ms 3432 KB Output is correct
34 Correct 33 ms 3308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 2 ms 492 KB Output is correct
7 Correct 4 ms 620 KB Output is correct
8 Correct 8 ms 876 KB Output is correct
9 Correct 16 ms 1516 KB Output is correct
10 Correct 2 ms 364 KB Output is correct
11 Correct 10 ms 1132 KB Output is correct
12 Correct 20 ms 1516 KB Output is correct
13 Correct 15 ms 1516 KB Output is correct
14 Correct 16 ms 1388 KB Output is correct
15 Correct 39 ms 3180 KB Output is correct
16 Correct 40 ms 3236 KB Output is correct
17 Correct 29 ms 3176 KB Output is correct
18 Correct 35 ms 3272 KB Output is correct
19 Correct 46 ms 3180 KB Output is correct
20 Correct 40 ms 3180 KB Output is correct
21 Correct 29 ms 3176 KB Output is correct
22 Correct 36 ms 3052 KB Output is correct
23 Correct 42 ms 3308 KB Output is correct
24 Correct 43 ms 3308 KB Output is correct
25 Correct 32 ms 3304 KB Output is correct
26 Correct 36 ms 3308 KB Output is correct
27 Correct 48 ms 3308 KB Output is correct
28 Correct 48 ms 3308 KB Output is correct
29 Correct 32 ms 3336 KB Output is correct
30 Correct 33 ms 3180 KB Output is correct
31 Correct 61 ms 3436 KB Output is correct
32 Correct 45 ms 3436 KB Output is correct
33 Correct 32 ms 3432 KB Output is correct
34 Correct 33 ms 3308 KB Output is correct
35 Correct 50 ms 3564 KB Output is correct
36 Correct 50 ms 3564 KB Output is correct
37 Correct 33 ms 3432 KB Output is correct
38 Correct 35 ms 3308 KB Output is correct