Submission #501628

# Submission time Handle Problem Language Result Execution time Memory
501628 2022-01-04T08:50:36 Z 79brue Minerals (JOI19_minerals) C++14
90 / 100
36 ms 2772 KB
#include "minerals.h"
#include <bits/stdc++.h>

typedef long long ll;

using namespace std;

int n;
bool chk[100002];
int order[100002], ocnt;
int ans[100002];
bool in[100002];
int lastRet;

int query(int x){
    in[x] = !in[x];
    return Query(order[x]);
}

void solve(int l, int r, vector<int>& vec){
    if(l==r){
        ans[l] = vec[0];
        return;
    }
    int m = (l+r)>>1;
    if(r-m < m-l+1) m--;

    int tmpCalc = 0;
    bool st = 0;
    for(int i=l; i<=m; i++) if(!in[i]) tmpCalc++;
    for(int i=m+1; i<=r; i++) if(in[i]) tmpCalc++;
    if(tmpCalc * 2 > r-l+1) st = 1;

    for(int i=l; i<=m; i++){
        if(in[i] == st) lastRet = query(i);
    }
    for(int i=m+1; i<=r; i++){
        if(in[i] != st) lastRet = query(i);
    }

    vector<int> lVec, rVec;
    for(auto x: vec){
        if((int)lVec.size() == m-l+1){
            rVec.push_back(x);
            continue;
        }
        else if((int)rVec.size() == r-m){
            lVec.push_back(x);
            continue;
        }
        int tmp = query(x);
        if((tmp == lastRet) ^ st) lVec.push_back(x);
        else rVec.push_back(x);
        lastRet = tmp;
    }

    solve(l, m, lVec);
    solve(m+1, r, rVec);
}

void Solve(int N){
    n = N;
    for(int i=1; i<=n+n; i++){
        int tmp = Query(i);
        if(tmp != lastRet) order[++ocnt] = i, chk[i] = 1;
        lastRet = tmp;
        in[i] = 1;
    }
    for(int i=1; i<=n+n; i++) if(!chk[i]) order[++ocnt] = i;

    vector<int> tVec;
    for(int i=n+1; i<=n+n; i++) tVec.push_back(i);
    solve(1, n, tVec);
    for(int i=1; i<=n; i++) Answer(order[i], order[ans[i]]);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 328 KB Output is correct
3 Correct 0 ms 328 KB Output is correct
4 Correct 0 ms 328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 2 ms 328 KB Output is correct
3 Correct 3 ms 456 KB Output is correct
4 Correct 5 ms 712 KB Output is correct
5 Correct 14 ms 1096 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 328 KB Output is correct
3 Correct 0 ms 328 KB Output is correct
4 Correct 0 ms 328 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 2 ms 328 KB Output is correct
7 Correct 3 ms 456 KB Output is correct
8 Correct 5 ms 712 KB Output is correct
9 Correct 14 ms 1096 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 7 ms 864 KB Output is correct
12 Correct 14 ms 1184 KB Output is correct
13 Correct 8 ms 1160 KB Output is correct
14 Correct 10 ms 1096 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 328 KB Output is correct
3 Correct 0 ms 328 KB Output is correct
4 Correct 0 ms 328 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 2 ms 328 KB Output is correct
7 Correct 3 ms 456 KB Output is correct
8 Correct 5 ms 712 KB Output is correct
9 Correct 14 ms 1096 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 7 ms 864 KB Output is correct
12 Correct 14 ms 1184 KB Output is correct
13 Correct 8 ms 1160 KB Output is correct
14 Correct 10 ms 1096 KB Output is correct
15 Correct 28 ms 2484 KB Output is correct
16 Correct 29 ms 2440 KB Output is correct
17 Correct 26 ms 2608 KB Output is correct
18 Correct 27 ms 2476 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 328 KB Output is correct
3 Correct 0 ms 328 KB Output is correct
4 Correct 0 ms 328 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 2 ms 328 KB Output is correct
7 Correct 3 ms 456 KB Output is correct
8 Correct 5 ms 712 KB Output is correct
9 Correct 14 ms 1096 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 7 ms 864 KB Output is correct
12 Correct 14 ms 1184 KB Output is correct
13 Correct 8 ms 1160 KB Output is correct
14 Correct 10 ms 1096 KB Output is correct
15 Correct 28 ms 2484 KB Output is correct
16 Correct 29 ms 2440 KB Output is correct
17 Correct 26 ms 2608 KB Output is correct
18 Correct 27 ms 2476 KB Output is correct
19 Correct 33 ms 2472 KB Output is correct
20 Correct 36 ms 2528 KB Output is correct
21 Correct 21 ms 2648 KB Output is correct
22 Correct 23 ms 2480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 328 KB Output is correct
3 Correct 0 ms 328 KB Output is correct
4 Correct 0 ms 328 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 2 ms 328 KB Output is correct
7 Correct 3 ms 456 KB Output is correct
8 Correct 5 ms 712 KB Output is correct
9 Correct 14 ms 1096 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 7 ms 864 KB Output is correct
12 Correct 14 ms 1184 KB Output is correct
13 Correct 8 ms 1160 KB Output is correct
14 Correct 10 ms 1096 KB Output is correct
15 Correct 28 ms 2484 KB Output is correct
16 Correct 29 ms 2440 KB Output is correct
17 Correct 26 ms 2608 KB Output is correct
18 Correct 27 ms 2476 KB Output is correct
19 Correct 33 ms 2472 KB Output is correct
20 Correct 36 ms 2528 KB Output is correct
21 Correct 21 ms 2648 KB Output is correct
22 Correct 23 ms 2480 KB Output is correct
23 Correct 31 ms 2468 KB Output is correct
24 Correct 33 ms 2668 KB Output is correct
25 Correct 21 ms 2620 KB Output is correct
26 Correct 23 ms 2524 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 328 KB Output is correct
3 Correct 0 ms 328 KB Output is correct
4 Correct 0 ms 328 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 2 ms 328 KB Output is correct
7 Correct 3 ms 456 KB Output is correct
8 Correct 5 ms 712 KB Output is correct
9 Correct 14 ms 1096 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 7 ms 864 KB Output is correct
12 Correct 14 ms 1184 KB Output is correct
13 Correct 8 ms 1160 KB Output is correct
14 Correct 10 ms 1096 KB Output is correct
15 Correct 28 ms 2484 KB Output is correct
16 Correct 29 ms 2440 KB Output is correct
17 Correct 26 ms 2608 KB Output is correct
18 Correct 27 ms 2476 KB Output is correct
19 Correct 33 ms 2472 KB Output is correct
20 Correct 36 ms 2528 KB Output is correct
21 Correct 21 ms 2648 KB Output is correct
22 Correct 23 ms 2480 KB Output is correct
23 Correct 31 ms 2468 KB Output is correct
24 Correct 33 ms 2668 KB Output is correct
25 Correct 21 ms 2620 KB Output is correct
26 Correct 23 ms 2524 KB Output is correct
27 Correct 32 ms 2620 KB Output is correct
28 Correct 30 ms 2592 KB Output is correct
29 Correct 22 ms 2772 KB Output is correct
30 Correct 27 ms 2724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 328 KB Output is correct
3 Correct 0 ms 328 KB Output is correct
4 Correct 0 ms 328 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 2 ms 328 KB Output is correct
7 Correct 3 ms 456 KB Output is correct
8 Correct 5 ms 712 KB Output is correct
9 Correct 14 ms 1096 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 7 ms 864 KB Output is correct
12 Correct 14 ms 1184 KB Output is correct
13 Correct 8 ms 1160 KB Output is correct
14 Correct 10 ms 1096 KB Output is correct
15 Correct 28 ms 2484 KB Output is correct
16 Correct 29 ms 2440 KB Output is correct
17 Correct 26 ms 2608 KB Output is correct
18 Correct 27 ms 2476 KB Output is correct
19 Correct 33 ms 2472 KB Output is correct
20 Correct 36 ms 2528 KB Output is correct
21 Correct 21 ms 2648 KB Output is correct
22 Correct 23 ms 2480 KB Output is correct
23 Correct 31 ms 2468 KB Output is correct
24 Correct 33 ms 2668 KB Output is correct
25 Correct 21 ms 2620 KB Output is correct
26 Correct 23 ms 2524 KB Output is correct
27 Correct 32 ms 2620 KB Output is correct
28 Correct 30 ms 2592 KB Output is correct
29 Correct 22 ms 2772 KB Output is correct
30 Correct 27 ms 2724 KB Output is correct
31 Correct 36 ms 2588 KB Output is correct
32 Correct 34 ms 2620 KB Output is correct
33 Correct 22 ms 2740 KB Output is correct
34 Correct 23 ms 2596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 328 KB Output is correct
3 Correct 0 ms 328 KB Output is correct
4 Correct 0 ms 328 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 2 ms 328 KB Output is correct
7 Correct 3 ms 456 KB Output is correct
8 Correct 5 ms 712 KB Output is correct
9 Correct 14 ms 1096 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 7 ms 864 KB Output is correct
12 Correct 14 ms 1184 KB Output is correct
13 Correct 8 ms 1160 KB Output is correct
14 Correct 10 ms 1096 KB Output is correct
15 Correct 28 ms 2484 KB Output is correct
16 Correct 29 ms 2440 KB Output is correct
17 Correct 26 ms 2608 KB Output is correct
18 Correct 27 ms 2476 KB Output is correct
19 Correct 33 ms 2472 KB Output is correct
20 Correct 36 ms 2528 KB Output is correct
21 Correct 21 ms 2648 KB Output is correct
22 Correct 23 ms 2480 KB Output is correct
23 Correct 31 ms 2468 KB Output is correct
24 Correct 33 ms 2668 KB Output is correct
25 Correct 21 ms 2620 KB Output is correct
26 Correct 23 ms 2524 KB Output is correct
27 Correct 32 ms 2620 KB Output is correct
28 Correct 30 ms 2592 KB Output is correct
29 Correct 22 ms 2772 KB Output is correct
30 Correct 27 ms 2724 KB Output is correct
31 Correct 36 ms 2588 KB Output is correct
32 Correct 34 ms 2620 KB Output is correct
33 Correct 22 ms 2740 KB Output is correct
34 Correct 23 ms 2596 KB Output is correct
35 Incorrect 33 ms 2524 KB Wrong Answer [2]
36 Halted 0 ms 0 KB -