답안 #250094

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
250094 2020-07-17T02:06:54 Z dantoh000 Minerals (JOI19_minerals) C++14
80 / 100
49 ms 2704 KB
#include <bits/stdc++.h>
#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 flag1, int flag2){
    if (r == l){
        //printf("%d -> %d\n",Q[l],p[0]);
        ans[Q[l]] = p[0];
        return;
    }
#ifdef debug
    printf("new %d %d\n",flag1,flag2);
    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 mid = (l+r)/2;
    int last;
    if (flag2){
        for (int i = mid+1; i <= r; i++){
        #ifdef debug
            printf("solve: removing %d\n",Q[i]);
        #endif
            last = Query(Q[i]);
        }
    }
    else{
        for (int i = l; i <= mid; i++){
        #ifdef debug
            printf("solve: adding %d\n",Q[i]);
        #endif
            last = Query(Q[i]);
        }
    }
    if (flag1){
        for (int i = 0; i < n; i++){
        #ifdef debug
            printf("solve: removing %d\n",p[i]);
        #endif
            int q = Query(p[i]);
            if (q == last){
                Lp.push_back(p[i]);
            }
            else{
                Rp.push_back(p[i]);
            }
            last = q;
        }
    }
    else{
        for (int i = 0; i < n; i++){
        #ifdef debug
            printf("solve: adding %d\n",p[i]);
        #endif
            int q = Query(p[i]);
            if (q == last){
                Lp.push_back(p[i]);
            }
            else{
                Rp.push_back(p[i]);
            }
            last = q;
        }

    }
    solve(Lp, l, mid, 1^flag1, 1);
    solve(Rp, mid+1, r, 1^flag1, 0);

}
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,1);
    for (auto x: Q){
        Answer(x,ans[x]);
    }
}

Compilation message

minerals.cpp: In function 'void solve(std::vector<int>, int, int, int, int)':
minerals.cpp:52:13: warning: 'last' may be used uninitialized in this function [-Wmaybe-uninitialized]
             if (q == last){
             ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 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 9 ms 768 KB Output is correct
5 Correct 17 ms 1088 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 1 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 9 ms 768 KB Output is correct
9 Correct 17 ms 1088 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 11 ms 1008 KB Output is correct
12 Correct 15 ms 1224 KB Output is correct
13 Correct 14 ms 1244 KB Output is correct
14 Correct 14 ms 1096 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 1 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 9 ms 768 KB Output is correct
9 Correct 17 ms 1088 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 11 ms 1008 KB Output is correct
12 Correct 15 ms 1224 KB Output is correct
13 Correct 14 ms 1244 KB Output is correct
14 Correct 14 ms 1096 KB Output is correct
15 Correct 40 ms 2536 KB Output is correct
16 Correct 41 ms 2548 KB Output is correct
17 Correct 33 ms 2436 KB Output is correct
18 Correct 38 ms 2320 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 1 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 9 ms 768 KB Output is correct
9 Correct 17 ms 1088 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 11 ms 1008 KB Output is correct
12 Correct 15 ms 1224 KB Output is correct
13 Correct 14 ms 1244 KB Output is correct
14 Correct 14 ms 1096 KB Output is correct
15 Correct 40 ms 2536 KB Output is correct
16 Correct 41 ms 2548 KB Output is correct
17 Correct 33 ms 2436 KB Output is correct
18 Correct 38 ms 2320 KB Output is correct
19 Correct 48 ms 2664 KB Output is correct
20 Correct 42 ms 2604 KB Output is correct
21 Correct 33 ms 2564 KB Output is correct
22 Correct 34 ms 2184 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 1 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 9 ms 768 KB Output is correct
9 Correct 17 ms 1088 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 11 ms 1008 KB Output is correct
12 Correct 15 ms 1224 KB Output is correct
13 Correct 14 ms 1244 KB Output is correct
14 Correct 14 ms 1096 KB Output is correct
15 Correct 40 ms 2536 KB Output is correct
16 Correct 41 ms 2548 KB Output is correct
17 Correct 33 ms 2436 KB Output is correct
18 Correct 38 ms 2320 KB Output is correct
19 Correct 48 ms 2664 KB Output is correct
20 Correct 42 ms 2604 KB Output is correct
21 Correct 33 ms 2564 KB Output is correct
22 Correct 34 ms 2184 KB Output is correct
23 Correct 44 ms 2576 KB Output is correct
24 Correct 49 ms 2704 KB Output is correct
25 Correct 34 ms 2564 KB Output is correct
26 Correct 35 ms 2300 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 1 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 9 ms 768 KB Output is correct
9 Correct 17 ms 1088 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 11 ms 1008 KB Output is correct
12 Correct 15 ms 1224 KB Output is correct
13 Correct 14 ms 1244 KB Output is correct
14 Correct 14 ms 1096 KB Output is correct
15 Correct 40 ms 2536 KB Output is correct
16 Correct 41 ms 2548 KB Output is correct
17 Correct 33 ms 2436 KB Output is correct
18 Correct 38 ms 2320 KB Output is correct
19 Correct 48 ms 2664 KB Output is correct
20 Correct 42 ms 2604 KB Output is correct
21 Correct 33 ms 2564 KB Output is correct
22 Correct 34 ms 2184 KB Output is correct
23 Correct 44 ms 2576 KB Output is correct
24 Correct 49 ms 2704 KB Output is correct
25 Correct 34 ms 2564 KB Output is correct
26 Correct 35 ms 2300 KB Output is correct
27 Incorrect 43 ms 2676 KB Wrong Answer [2]
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 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 9 ms 768 KB Output is correct
9 Correct 17 ms 1088 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 11 ms 1008 KB Output is correct
12 Correct 15 ms 1224 KB Output is correct
13 Correct 14 ms 1244 KB Output is correct
14 Correct 14 ms 1096 KB Output is correct
15 Correct 40 ms 2536 KB Output is correct
16 Correct 41 ms 2548 KB Output is correct
17 Correct 33 ms 2436 KB Output is correct
18 Correct 38 ms 2320 KB Output is correct
19 Correct 48 ms 2664 KB Output is correct
20 Correct 42 ms 2604 KB Output is correct
21 Correct 33 ms 2564 KB Output is correct
22 Correct 34 ms 2184 KB Output is correct
23 Correct 44 ms 2576 KB Output is correct
24 Correct 49 ms 2704 KB Output is correct
25 Correct 34 ms 2564 KB Output is correct
26 Correct 35 ms 2300 KB Output is correct
27 Incorrect 43 ms 2676 KB Wrong Answer [2]
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 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 9 ms 768 KB Output is correct
9 Correct 17 ms 1088 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 11 ms 1008 KB Output is correct
12 Correct 15 ms 1224 KB Output is correct
13 Correct 14 ms 1244 KB Output is correct
14 Correct 14 ms 1096 KB Output is correct
15 Correct 40 ms 2536 KB Output is correct
16 Correct 41 ms 2548 KB Output is correct
17 Correct 33 ms 2436 KB Output is correct
18 Correct 38 ms 2320 KB Output is correct
19 Correct 48 ms 2664 KB Output is correct
20 Correct 42 ms 2604 KB Output is correct
21 Correct 33 ms 2564 KB Output is correct
22 Correct 34 ms 2184 KB Output is correct
23 Correct 44 ms 2576 KB Output is correct
24 Correct 49 ms 2704 KB Output is correct
25 Correct 34 ms 2564 KB Output is correct
26 Correct 35 ms 2300 KB Output is correct
27 Incorrect 43 ms 2676 KB Wrong Answer [2]
28 Halted 0 ms 0 KB -