답안 #378175

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
378175 2021-03-16T06:32:38 Z 2qbingxuan Minerals (JOI19_minerals) C++14
70 / 100
47 ms 2824 KB
#include "minerals.h"
#include <bits/stdc++.h>
using namespace std;
 
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 = A.size() / 2;
    for (int i = 0; i < m; i++)
        cur = Query(A[i]);
    vector<int> L, R;
    for (int x: B) {
        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) {
            Query(i);
            A.push_back(i);
        } else {
            B.push_back(i);
        }
        cur = q;
    }
    dq(A, B, false);
    // 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);
    }
    */
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 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 3 ms 512 KB Output is correct
3 Correct 4 ms 620 KB Output is correct
4 Correct 9 ms 748 KB Output is correct
5 Correct 16 ms 1260 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 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 3 ms 512 KB Output is correct
7 Correct 4 ms 620 KB Output is correct
8 Correct 9 ms 748 KB Output is correct
9 Correct 16 ms 1260 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 10 ms 1004 KB Output is correct
12 Correct 16 ms 1260 KB Output is correct
13 Correct 13 ms 1260 KB Output is correct
14 Correct 13 ms 1260 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 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 3 ms 512 KB Output is correct
7 Correct 4 ms 620 KB Output is correct
8 Correct 9 ms 748 KB Output is correct
9 Correct 16 ms 1260 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 10 ms 1004 KB Output is correct
12 Correct 16 ms 1260 KB Output is correct
13 Correct 13 ms 1260 KB Output is correct
14 Correct 13 ms 1260 KB Output is correct
15 Correct 42 ms 2796 KB Output is correct
16 Correct 47 ms 2796 KB Output is correct
17 Correct 31 ms 2792 KB Output is correct
18 Correct 36 ms 2668 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 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 3 ms 512 KB Output is correct
7 Correct 4 ms 620 KB Output is correct
8 Correct 9 ms 748 KB Output is correct
9 Correct 16 ms 1260 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 10 ms 1004 KB Output is correct
12 Correct 16 ms 1260 KB Output is correct
13 Correct 13 ms 1260 KB Output is correct
14 Correct 13 ms 1260 KB Output is correct
15 Correct 42 ms 2796 KB Output is correct
16 Correct 47 ms 2796 KB Output is correct
17 Correct 31 ms 2792 KB Output is correct
18 Correct 36 ms 2668 KB Output is correct
19 Incorrect 44 ms 2824 KB Wrong Answer [2]
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 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 3 ms 512 KB Output is correct
7 Correct 4 ms 620 KB Output is correct
8 Correct 9 ms 748 KB Output is correct
9 Correct 16 ms 1260 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 10 ms 1004 KB Output is correct
12 Correct 16 ms 1260 KB Output is correct
13 Correct 13 ms 1260 KB Output is correct
14 Correct 13 ms 1260 KB Output is correct
15 Correct 42 ms 2796 KB Output is correct
16 Correct 47 ms 2796 KB Output is correct
17 Correct 31 ms 2792 KB Output is correct
18 Correct 36 ms 2668 KB Output is correct
19 Incorrect 44 ms 2824 KB Wrong Answer [2]
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 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 3 ms 512 KB Output is correct
7 Correct 4 ms 620 KB Output is correct
8 Correct 9 ms 748 KB Output is correct
9 Correct 16 ms 1260 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 10 ms 1004 KB Output is correct
12 Correct 16 ms 1260 KB Output is correct
13 Correct 13 ms 1260 KB Output is correct
14 Correct 13 ms 1260 KB Output is correct
15 Correct 42 ms 2796 KB Output is correct
16 Correct 47 ms 2796 KB Output is correct
17 Correct 31 ms 2792 KB Output is correct
18 Correct 36 ms 2668 KB Output is correct
19 Incorrect 44 ms 2824 KB Wrong Answer [2]
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 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 3 ms 512 KB Output is correct
7 Correct 4 ms 620 KB Output is correct
8 Correct 9 ms 748 KB Output is correct
9 Correct 16 ms 1260 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 10 ms 1004 KB Output is correct
12 Correct 16 ms 1260 KB Output is correct
13 Correct 13 ms 1260 KB Output is correct
14 Correct 13 ms 1260 KB Output is correct
15 Correct 42 ms 2796 KB Output is correct
16 Correct 47 ms 2796 KB Output is correct
17 Correct 31 ms 2792 KB Output is correct
18 Correct 36 ms 2668 KB Output is correct
19 Incorrect 44 ms 2824 KB Wrong Answer [2]
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 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 3 ms 512 KB Output is correct
7 Correct 4 ms 620 KB Output is correct
8 Correct 9 ms 748 KB Output is correct
9 Correct 16 ms 1260 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 10 ms 1004 KB Output is correct
12 Correct 16 ms 1260 KB Output is correct
13 Correct 13 ms 1260 KB Output is correct
14 Correct 13 ms 1260 KB Output is correct
15 Correct 42 ms 2796 KB Output is correct
16 Correct 47 ms 2796 KB Output is correct
17 Correct 31 ms 2792 KB Output is correct
18 Correct 36 ms 2668 KB Output is correct
19 Incorrect 44 ms 2824 KB Wrong Answer [2]
20 Halted 0 ms 0 KB -