답안 #250213

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
250213 2020-07-17T08:13:00 Z dantoh000 Minerals (JOI19_minerals) C++14
100 / 100
52 ms 3060 KB
#include <bits/stdc++.h>
using namespace std;
#include "minerals.h"
using namespace std;
vector<int> Q;
vector<int> P;
int ans[86005];
void solve(vector<int> p, int l, int r, int flag){
    if (r == l){
        //printf("%d -> %d\n",Q[l],p[0]);
        Answer(Q[l],p[0]);
        return;
    }
#ifdef debug
    for (auto x : p){
        printf("%d ",x);
    }
    printf("<- P\n");
    for (int i = l; i <= r; i++){
        printf("%d ",Q[i]);
    }
    printf("<- Q\n");
#endif
    //assert(p.size() == r-l+1);
    vector<int> Lp;
    vector<int> Rp;
    int n = r-l+1;
    int m = l +(r-l)*0.382;
    int last;

    for (int i = l; i <= m; i++){
        last = Query(Q[i]);
    }

    for (int i = 0; i < n; i++){
        if (Rp.size() == r-m) Lp.push_back(p[i]);
        else if (Lp.size() == m-l+1) Rp.push_back(p[i]);
        else{
            int q = Query(p[i]);
            if ((q == last) != flag){
                Lp.push_back(p[i]);
            }
            else{
                Rp.push_back(p[i]);
            }

            last = q;
        }
    }


    solve(Lp, l, m,  !flag);
    solve(Rp, m+1, r, flag);

}
void Solve(int N) {
    int last = 0;
    for (int i = 1; i <= 2*N; i++){
        int q = Query(i);
        if (q == last){
            Q.push_back(i);
        }
        else{
            P.push_back(i);
        }
        last = q;
    }
    solve(P,0,N-1,1);
}

Compilation message

minerals.cpp: In function 'void solve(std::vector<int>, int, int, int)':
minerals.cpp:37:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (Rp.size() == r-m) Lp.push_back(p[i]);
             ~~~~~~~~~~^~~~~~
minerals.cpp:38:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         else if (Lp.size() == m-l+1) Rp.push_back(p[i]);
                  ~~~~~~~~~~^~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 2 ms 512 KB Output is correct
3 Correct 4 ms 512 KB Output is correct
4 Correct 8 ms 768 KB Output is correct
5 Correct 15 ms 1280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 2 ms 512 KB Output is correct
7 Correct 4 ms 512 KB Output is correct
8 Correct 8 ms 768 KB Output is correct
9 Correct 15 ms 1280 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 10 ms 1024 KB Output is correct
12 Correct 16 ms 1280 KB Output is correct
13 Correct 13 ms 1280 KB Output is correct
14 Correct 15 ms 1280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 2 ms 512 KB Output is correct
7 Correct 4 ms 512 KB Output is correct
8 Correct 8 ms 768 KB Output is correct
9 Correct 15 ms 1280 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 10 ms 1024 KB Output is correct
12 Correct 16 ms 1280 KB Output is correct
13 Correct 13 ms 1280 KB Output is correct
14 Correct 15 ms 1280 KB Output is correct
15 Correct 46 ms 2676 KB Output is correct
16 Correct 43 ms 2720 KB Output is correct
17 Correct 31 ms 2676 KB Output is correct
18 Correct 32 ms 2612 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 2 ms 512 KB Output is correct
7 Correct 4 ms 512 KB Output is correct
8 Correct 8 ms 768 KB Output is correct
9 Correct 15 ms 1280 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 10 ms 1024 KB Output is correct
12 Correct 16 ms 1280 KB Output is correct
13 Correct 13 ms 1280 KB Output is correct
14 Correct 15 ms 1280 KB Output is correct
15 Correct 46 ms 2676 KB Output is correct
16 Correct 43 ms 2720 KB Output is correct
17 Correct 31 ms 2676 KB Output is correct
18 Correct 32 ms 2612 KB Output is correct
19 Correct 48 ms 2804 KB Output is correct
20 Correct 52 ms 2780 KB Output is correct
21 Correct 35 ms 2788 KB Output is correct
22 Correct 32 ms 2604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 2 ms 512 KB Output is correct
7 Correct 4 ms 512 KB Output is correct
8 Correct 8 ms 768 KB Output is correct
9 Correct 15 ms 1280 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 10 ms 1024 KB Output is correct
12 Correct 16 ms 1280 KB Output is correct
13 Correct 13 ms 1280 KB Output is correct
14 Correct 15 ms 1280 KB Output is correct
15 Correct 46 ms 2676 KB Output is correct
16 Correct 43 ms 2720 KB Output is correct
17 Correct 31 ms 2676 KB Output is correct
18 Correct 32 ms 2612 KB Output is correct
19 Correct 48 ms 2804 KB Output is correct
20 Correct 52 ms 2780 KB Output is correct
21 Correct 35 ms 2788 KB Output is correct
22 Correct 32 ms 2604 KB Output is correct
23 Correct 49 ms 2804 KB Output is correct
24 Correct 44 ms 2932 KB Output is correct
25 Correct 33 ms 2892 KB Output is correct
26 Correct 34 ms 2728 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 2 ms 512 KB Output is correct
7 Correct 4 ms 512 KB Output is correct
8 Correct 8 ms 768 KB Output is correct
9 Correct 15 ms 1280 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 10 ms 1024 KB Output is correct
12 Correct 16 ms 1280 KB Output is correct
13 Correct 13 ms 1280 KB Output is correct
14 Correct 15 ms 1280 KB Output is correct
15 Correct 46 ms 2676 KB Output is correct
16 Correct 43 ms 2720 KB Output is correct
17 Correct 31 ms 2676 KB Output is correct
18 Correct 32 ms 2612 KB Output is correct
19 Correct 48 ms 2804 KB Output is correct
20 Correct 52 ms 2780 KB Output is correct
21 Correct 35 ms 2788 KB Output is correct
22 Correct 32 ms 2604 KB Output is correct
23 Correct 49 ms 2804 KB Output is correct
24 Correct 44 ms 2932 KB Output is correct
25 Correct 33 ms 2892 KB Output is correct
26 Correct 34 ms 2728 KB Output is correct
27 Correct 48 ms 2932 KB Output is correct
28 Correct 48 ms 2884 KB Output is correct
29 Correct 35 ms 2888 KB Output is correct
30 Correct 37 ms 2728 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 2 ms 512 KB Output is correct
7 Correct 4 ms 512 KB Output is correct
8 Correct 8 ms 768 KB Output is correct
9 Correct 15 ms 1280 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 10 ms 1024 KB Output is correct
12 Correct 16 ms 1280 KB Output is correct
13 Correct 13 ms 1280 KB Output is correct
14 Correct 15 ms 1280 KB Output is correct
15 Correct 46 ms 2676 KB Output is correct
16 Correct 43 ms 2720 KB Output is correct
17 Correct 31 ms 2676 KB Output is correct
18 Correct 32 ms 2612 KB Output is correct
19 Correct 48 ms 2804 KB Output is correct
20 Correct 52 ms 2780 KB Output is correct
21 Correct 35 ms 2788 KB Output is correct
22 Correct 32 ms 2604 KB Output is correct
23 Correct 49 ms 2804 KB Output is correct
24 Correct 44 ms 2932 KB Output is correct
25 Correct 33 ms 2892 KB Output is correct
26 Correct 34 ms 2728 KB Output is correct
27 Correct 48 ms 2932 KB Output is correct
28 Correct 48 ms 2884 KB Output is correct
29 Correct 35 ms 2888 KB Output is correct
30 Correct 37 ms 2728 KB Output is correct
31 Correct 47 ms 2932 KB Output is correct
32 Correct 47 ms 3060 KB Output is correct
33 Correct 34 ms 2884 KB Output is correct
34 Correct 38 ms 2816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 2 ms 512 KB Output is correct
7 Correct 4 ms 512 KB Output is correct
8 Correct 8 ms 768 KB Output is correct
9 Correct 15 ms 1280 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 10 ms 1024 KB Output is correct
12 Correct 16 ms 1280 KB Output is correct
13 Correct 13 ms 1280 KB Output is correct
14 Correct 15 ms 1280 KB Output is correct
15 Correct 46 ms 2676 KB Output is correct
16 Correct 43 ms 2720 KB Output is correct
17 Correct 31 ms 2676 KB Output is correct
18 Correct 32 ms 2612 KB Output is correct
19 Correct 48 ms 2804 KB Output is correct
20 Correct 52 ms 2780 KB Output is correct
21 Correct 35 ms 2788 KB Output is correct
22 Correct 32 ms 2604 KB Output is correct
23 Correct 49 ms 2804 KB Output is correct
24 Correct 44 ms 2932 KB Output is correct
25 Correct 33 ms 2892 KB Output is correct
26 Correct 34 ms 2728 KB Output is correct
27 Correct 48 ms 2932 KB Output is correct
28 Correct 48 ms 2884 KB Output is correct
29 Correct 35 ms 2888 KB Output is correct
30 Correct 37 ms 2728 KB Output is correct
31 Correct 47 ms 2932 KB Output is correct
32 Correct 47 ms 3060 KB Output is correct
33 Correct 34 ms 2884 KB Output is correct
34 Correct 38 ms 2816 KB Output is correct
35 Correct 47 ms 3060 KB Output is correct
36 Correct 50 ms 2932 KB Output is correct
37 Correct 36 ms 2968 KB Output is correct
38 Correct 40 ms 2804 KB Output is correct