답안 #120622

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
120622 2019-06-25T06:03:39 Z 이온조(#2959) Minerals (JOI19_minerals) C++14
80 / 100
44 ms 2756 KB
#include "minerals.h"
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;

int query(int x) {
    //printf("query x: %d\n", x);
    return Query(x);
}

void answer(int a, int b) {
    //printf("answer: (%d, %d)\n", a, b);
    Answer(a, b);
}

pair<vi, vi> split(int N) {
    vector<int> A, B;
    int pr = 0;
    for(int i=1; i<=2*N; i++) {
        int Q = query(i);
        if(pr != Q) A.push_back(i);
        else B.push_back(i);
        pr = Q;
    }
    return {A, B};
}

void go(vector<int> &A, vector<int> &B, bool AC, bool BC) {
    int N = A.size();
    if(N == 1) {
        answer(A[0], B[0]);
        return;
    }
    if(!AC) {
        int m = N/2, pr;
        vector<int> LA, RA, LB, RB;
        for(int i=0; i<m; i++) {
            pr = query(A[i]);
            LA.push_back(A[i]);
        }
        for(int i=m; i<N; i++) RA.push_back(A[i]);
        for(int i=0; i<N; i++) {
            int Q = query(B[i]);
            if(pr != Q) RB.push_back(B[i]);
            else LB.push_back(B[i]);
            pr = Q;
        }
        go(LA, LB, 1, !BC);
        go(RA, RB, 0, !BC);
    }
    if(AC) {
        int m = N/2, pr;
        vector<int> LA, RA, LB, RB;
        for(int i=0; i<m; i++) {
            pr = query(A[i]);
            LA.push_back(A[i]);
        }
        for(int i=m; i<N; i++) RA.push_back(A[i]);
        for(int i=0; i<N; i++) {
            int Q = query(B[i]);
            if(pr != Q) LB.push_back(B[i]);
            else RB.push_back(B[i]);
            pr = Q;
        }
        go(LA, LB, 0, !BC);
        go(RA, RB, 1, !BC);
    }
}

void Solve(int N) {
    vi A, B; tie(A, B) = split(N);
    go(A, B, 1, 1);
}

Compilation message

minerals.cpp: In function 'void go(std::vector<int>&, std::vector<int>&, bool, bool)':
minerals.cpp:61:13: warning: 'pr' may be used uninitialized in this function [-Wmaybe-uninitialized]
             if(pr != Q) LB.push_back(B[i]);
             ^~
minerals.cpp:44:13: warning: 'pr' may be used uninitialized in this function [-Wmaybe-uninitialized]
             if(pr != Q) RB.push_back(B[i]);
             ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 4 ms 512 KB Output is correct
3 Correct 8 ms 512 KB Output is correct
4 Correct 8 ms 640 KB Output is correct
5 Correct 15 ms 1080 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 4 ms 512 KB Output is correct
7 Correct 8 ms 512 KB Output is correct
8 Correct 8 ms 640 KB Output is correct
9 Correct 15 ms 1080 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 11 ms 1024 KB Output is correct
12 Correct 15 ms 1152 KB Output is correct
13 Correct 12 ms 1152 KB Output is correct
14 Correct 13 ms 1024 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 4 ms 512 KB Output is correct
7 Correct 8 ms 512 KB Output is correct
8 Correct 8 ms 640 KB Output is correct
9 Correct 15 ms 1080 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 11 ms 1024 KB Output is correct
12 Correct 15 ms 1152 KB Output is correct
13 Correct 12 ms 1152 KB Output is correct
14 Correct 13 ms 1024 KB Output is correct
15 Correct 40 ms 2636 KB Output is correct
16 Correct 41 ms 2648 KB Output is correct
17 Correct 31 ms 2500 KB Output is correct
18 Correct 30 ms 2372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 4 ms 512 KB Output is correct
7 Correct 8 ms 512 KB Output is correct
8 Correct 8 ms 640 KB Output is correct
9 Correct 15 ms 1080 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 11 ms 1024 KB Output is correct
12 Correct 15 ms 1152 KB Output is correct
13 Correct 12 ms 1152 KB Output is correct
14 Correct 13 ms 1024 KB Output is correct
15 Correct 40 ms 2636 KB Output is correct
16 Correct 41 ms 2648 KB Output is correct
17 Correct 31 ms 2500 KB Output is correct
18 Correct 30 ms 2372 KB Output is correct
19 Correct 40 ms 2628 KB Output is correct
20 Correct 42 ms 2756 KB Output is correct
21 Correct 31 ms 2648 KB Output is correct
22 Correct 38 ms 2364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 4 ms 512 KB Output is correct
7 Correct 8 ms 512 KB Output is correct
8 Correct 8 ms 640 KB Output is correct
9 Correct 15 ms 1080 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 11 ms 1024 KB Output is correct
12 Correct 15 ms 1152 KB Output is correct
13 Correct 12 ms 1152 KB Output is correct
14 Correct 13 ms 1024 KB Output is correct
15 Correct 40 ms 2636 KB Output is correct
16 Correct 41 ms 2648 KB Output is correct
17 Correct 31 ms 2500 KB Output is correct
18 Correct 30 ms 2372 KB Output is correct
19 Correct 40 ms 2628 KB Output is correct
20 Correct 42 ms 2756 KB Output is correct
21 Correct 31 ms 2648 KB Output is correct
22 Correct 38 ms 2364 KB Output is correct
23 Correct 42 ms 2748 KB Output is correct
24 Correct 44 ms 2736 KB Output is correct
25 Correct 32 ms 2620 KB Output is correct
26 Correct 34 ms 2476 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 4 ms 512 KB Output is correct
7 Correct 8 ms 512 KB Output is correct
8 Correct 8 ms 640 KB Output is correct
9 Correct 15 ms 1080 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 11 ms 1024 KB Output is correct
12 Correct 15 ms 1152 KB Output is correct
13 Correct 12 ms 1152 KB Output is correct
14 Correct 13 ms 1024 KB Output is correct
15 Correct 40 ms 2636 KB Output is correct
16 Correct 41 ms 2648 KB Output is correct
17 Correct 31 ms 2500 KB Output is correct
18 Correct 30 ms 2372 KB Output is correct
19 Correct 40 ms 2628 KB Output is correct
20 Correct 42 ms 2756 KB Output is correct
21 Correct 31 ms 2648 KB Output is correct
22 Correct 38 ms 2364 KB Output is correct
23 Correct 42 ms 2748 KB Output is correct
24 Correct 44 ms 2736 KB Output is correct
25 Correct 32 ms 2620 KB Output is correct
26 Correct 34 ms 2476 KB Output is correct
27 Incorrect 43 ms 2748 KB Wrong Answer [2]
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 4 ms 512 KB Output is correct
7 Correct 8 ms 512 KB Output is correct
8 Correct 8 ms 640 KB Output is correct
9 Correct 15 ms 1080 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 11 ms 1024 KB Output is correct
12 Correct 15 ms 1152 KB Output is correct
13 Correct 12 ms 1152 KB Output is correct
14 Correct 13 ms 1024 KB Output is correct
15 Correct 40 ms 2636 KB Output is correct
16 Correct 41 ms 2648 KB Output is correct
17 Correct 31 ms 2500 KB Output is correct
18 Correct 30 ms 2372 KB Output is correct
19 Correct 40 ms 2628 KB Output is correct
20 Correct 42 ms 2756 KB Output is correct
21 Correct 31 ms 2648 KB Output is correct
22 Correct 38 ms 2364 KB Output is correct
23 Correct 42 ms 2748 KB Output is correct
24 Correct 44 ms 2736 KB Output is correct
25 Correct 32 ms 2620 KB Output is correct
26 Correct 34 ms 2476 KB Output is correct
27 Incorrect 43 ms 2748 KB Wrong Answer [2]
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 4 ms 512 KB Output is correct
7 Correct 8 ms 512 KB Output is correct
8 Correct 8 ms 640 KB Output is correct
9 Correct 15 ms 1080 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 11 ms 1024 KB Output is correct
12 Correct 15 ms 1152 KB Output is correct
13 Correct 12 ms 1152 KB Output is correct
14 Correct 13 ms 1024 KB Output is correct
15 Correct 40 ms 2636 KB Output is correct
16 Correct 41 ms 2648 KB Output is correct
17 Correct 31 ms 2500 KB Output is correct
18 Correct 30 ms 2372 KB Output is correct
19 Correct 40 ms 2628 KB Output is correct
20 Correct 42 ms 2756 KB Output is correct
21 Correct 31 ms 2648 KB Output is correct
22 Correct 38 ms 2364 KB Output is correct
23 Correct 42 ms 2748 KB Output is correct
24 Correct 44 ms 2736 KB Output is correct
25 Correct 32 ms 2620 KB Output is correct
26 Correct 34 ms 2476 KB Output is correct
27 Incorrect 43 ms 2748 KB Wrong Answer [2]
28 Halted 0 ms 0 KB -