답안 #705850

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
705850 2023-03-05T13:44:57 Z qwerasdfzxcl Minerals (JOI19_minerals) C++17
80 / 100
46 ms 4084 KB
#include "minerals.h"
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
int n, cur, ans[100100];

void dnc0(vector<int> a);
void dnc1(vector<int> L, vector<int> R, bool onL, bool onR);

int myquery(int x){
    cur = Query(x);
    return cur;
}

void dnc0(vector<int> a){
    int s0 = cur, c = a.size() / 2;

    if (c==0) return;
    if (c==1){
        ans[a[0]] = a[1];
        ans[a[1]] = a[0];
        return;
    }

    vector<int> L, R, Z;
    for (auto &x:a){
        int prv = cur;
        int now = myquery(x);
        if (now==prv){
            R.push_back(x);
        }
        else{
            L.push_back(x);
        }
    }

    dnc1(L, R, 1, 1);
}

void dnc1(vector<int> L, vector<int> R, bool onL, bool onR){
    // printf("dnc1: ");
    // for (auto &x:L) printf("%d ", x);
    // printf("\n");
    // for (auto &x:R) printf("%d ", x);
    // printf("\n");
    
    int c = L.size();

    if (c==0) return;
    if (c==1){
        ans[L[0]] = R[0];
        ans[R[0]] = L[0];
        return;
    }

    vector<int> L1, R1, L2, R2;
    for (int i=0;i<c/2;i++) {L1.push_back(L[i]); myquery(L[i]);}
    for (int i=c/2;i<c;i++) L2.push_back(L[i]);

    for (auto &x:R){
        int prv = cur;
        int delta = myquery(x) - prv;

        if ((!onL) == (delta==0)) R1.push_back(x);
        else R2.push_back(x);
    }

    dnc1(L1, R1, !onL, !onR);
    dnc1(L2, R2, onL, !onR);
}

void Solve(int N) {
    n = N, cur = 0;
    vector<int> a;
    for (int i=1;i<=n*2;i++) a.push_back(i);
    
    dnc0(a);

    for (int i=1;i<=n*2;i++) if (i < ans[i]) Answer(i, ans[i]);
}

Compilation message

minerals.cpp: In function 'void dnc0(std::vector<int>)':
minerals.cpp:17:9: warning: unused variable 's0' [-Wunused-variable]
   17 |     int s0 = cur, c = a.size() / 2;
      |         ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 336 KB Output is correct
2 Correct 2 ms 464 KB Output is correct
3 Correct 4 ms 592 KB Output is correct
4 Correct 7 ms 996 KB Output is correct
5 Correct 13 ms 1652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 2 ms 336 KB Output is correct
6 Correct 2 ms 464 KB Output is correct
7 Correct 4 ms 592 KB Output is correct
8 Correct 7 ms 996 KB Output is correct
9 Correct 13 ms 1652 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 11 ms 1252 KB Output is correct
12 Correct 14 ms 1744 KB Output is correct
13 Correct 14 ms 1708 KB Output is correct
14 Correct 12 ms 1692 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 2 ms 336 KB Output is correct
6 Correct 2 ms 464 KB Output is correct
7 Correct 4 ms 592 KB Output is correct
8 Correct 7 ms 996 KB Output is correct
9 Correct 13 ms 1652 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 11 ms 1252 KB Output is correct
12 Correct 14 ms 1744 KB Output is correct
13 Correct 14 ms 1708 KB Output is correct
14 Correct 12 ms 1692 KB Output is correct
15 Correct 40 ms 3904 KB Output is correct
16 Correct 38 ms 3772 KB Output is correct
17 Correct 31 ms 3600 KB Output is correct
18 Correct 31 ms 3536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 2 ms 336 KB Output is correct
6 Correct 2 ms 464 KB Output is correct
7 Correct 4 ms 592 KB Output is correct
8 Correct 7 ms 996 KB Output is correct
9 Correct 13 ms 1652 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 11 ms 1252 KB Output is correct
12 Correct 14 ms 1744 KB Output is correct
13 Correct 14 ms 1708 KB Output is correct
14 Correct 12 ms 1692 KB Output is correct
15 Correct 40 ms 3904 KB Output is correct
16 Correct 38 ms 3772 KB Output is correct
17 Correct 31 ms 3600 KB Output is correct
18 Correct 31 ms 3536 KB Output is correct
19 Correct 44 ms 3864 KB Output is correct
20 Correct 46 ms 3864 KB Output is correct
21 Correct 32 ms 3720 KB Output is correct
22 Correct 35 ms 3680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 2 ms 336 KB Output is correct
6 Correct 2 ms 464 KB Output is correct
7 Correct 4 ms 592 KB Output is correct
8 Correct 7 ms 996 KB Output is correct
9 Correct 13 ms 1652 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 11 ms 1252 KB Output is correct
12 Correct 14 ms 1744 KB Output is correct
13 Correct 14 ms 1708 KB Output is correct
14 Correct 12 ms 1692 KB Output is correct
15 Correct 40 ms 3904 KB Output is correct
16 Correct 38 ms 3772 KB Output is correct
17 Correct 31 ms 3600 KB Output is correct
18 Correct 31 ms 3536 KB Output is correct
19 Correct 44 ms 3864 KB Output is correct
20 Correct 46 ms 3864 KB Output is correct
21 Correct 32 ms 3720 KB Output is correct
22 Correct 35 ms 3680 KB Output is correct
23 Correct 40 ms 4084 KB Output is correct
24 Correct 38 ms 3924 KB Output is correct
25 Correct 33 ms 3872 KB Output is correct
26 Correct 39 ms 3796 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 2 ms 336 KB Output is correct
6 Correct 2 ms 464 KB Output is correct
7 Correct 4 ms 592 KB Output is correct
8 Correct 7 ms 996 KB Output is correct
9 Correct 13 ms 1652 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 11 ms 1252 KB Output is correct
12 Correct 14 ms 1744 KB Output is correct
13 Correct 14 ms 1708 KB Output is correct
14 Correct 12 ms 1692 KB Output is correct
15 Correct 40 ms 3904 KB Output is correct
16 Correct 38 ms 3772 KB Output is correct
17 Correct 31 ms 3600 KB Output is correct
18 Correct 31 ms 3536 KB Output is correct
19 Correct 44 ms 3864 KB Output is correct
20 Correct 46 ms 3864 KB Output is correct
21 Correct 32 ms 3720 KB Output is correct
22 Correct 35 ms 3680 KB Output is correct
23 Correct 40 ms 4084 KB Output is correct
24 Correct 38 ms 3924 KB Output is correct
25 Correct 33 ms 3872 KB Output is correct
26 Correct 39 ms 3796 KB Output is correct
27 Incorrect 38 ms 4012 KB Wrong Answer [2]
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 2 ms 336 KB Output is correct
6 Correct 2 ms 464 KB Output is correct
7 Correct 4 ms 592 KB Output is correct
8 Correct 7 ms 996 KB Output is correct
9 Correct 13 ms 1652 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 11 ms 1252 KB Output is correct
12 Correct 14 ms 1744 KB Output is correct
13 Correct 14 ms 1708 KB Output is correct
14 Correct 12 ms 1692 KB Output is correct
15 Correct 40 ms 3904 KB Output is correct
16 Correct 38 ms 3772 KB Output is correct
17 Correct 31 ms 3600 KB Output is correct
18 Correct 31 ms 3536 KB Output is correct
19 Correct 44 ms 3864 KB Output is correct
20 Correct 46 ms 3864 KB Output is correct
21 Correct 32 ms 3720 KB Output is correct
22 Correct 35 ms 3680 KB Output is correct
23 Correct 40 ms 4084 KB Output is correct
24 Correct 38 ms 3924 KB Output is correct
25 Correct 33 ms 3872 KB Output is correct
26 Correct 39 ms 3796 KB Output is correct
27 Incorrect 38 ms 4012 KB Wrong Answer [2]
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 2 ms 336 KB Output is correct
6 Correct 2 ms 464 KB Output is correct
7 Correct 4 ms 592 KB Output is correct
8 Correct 7 ms 996 KB Output is correct
9 Correct 13 ms 1652 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 11 ms 1252 KB Output is correct
12 Correct 14 ms 1744 KB Output is correct
13 Correct 14 ms 1708 KB Output is correct
14 Correct 12 ms 1692 KB Output is correct
15 Correct 40 ms 3904 KB Output is correct
16 Correct 38 ms 3772 KB Output is correct
17 Correct 31 ms 3600 KB Output is correct
18 Correct 31 ms 3536 KB Output is correct
19 Correct 44 ms 3864 KB Output is correct
20 Correct 46 ms 3864 KB Output is correct
21 Correct 32 ms 3720 KB Output is correct
22 Correct 35 ms 3680 KB Output is correct
23 Correct 40 ms 4084 KB Output is correct
24 Correct 38 ms 3924 KB Output is correct
25 Correct 33 ms 3872 KB Output is correct
26 Correct 39 ms 3796 KB Output is correct
27 Incorrect 38 ms 4012 KB Wrong Answer [2]
28 Halted 0 ms 0 KB -