Submission #501630

# Submission time Handle Problem Language Result Execution time Memory
501630 2022-01-04T08:52:42 Z 79brue Minerals (JOI19_minerals) C++14
80 / 100
41 ms 2676 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 328 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 704 KB Output is correct
5 Correct 13 ms 1096 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 328 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 704 KB Output is correct
9 Correct 13 ms 1096 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 9 ms 968 KB Output is correct
12 Correct 11 ms 1180 KB Output is correct
13 Correct 8 ms 1136 KB Output is correct
14 Correct 9 ms 1120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 328 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 704 KB Output is correct
9 Correct 13 ms 1096 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 9 ms 968 KB Output is correct
12 Correct 11 ms 1180 KB Output is correct
13 Correct 8 ms 1136 KB Output is correct
14 Correct 9 ms 1120 KB Output is correct
15 Correct 35 ms 2472 KB Output is correct
16 Correct 29 ms 2400 KB Output is correct
17 Correct 27 ms 2500 KB Output is correct
18 Correct 28 ms 2416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 328 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 704 KB Output is correct
9 Correct 13 ms 1096 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 9 ms 968 KB Output is correct
12 Correct 11 ms 1180 KB Output is correct
13 Correct 8 ms 1136 KB Output is correct
14 Correct 9 ms 1120 KB Output is correct
15 Correct 35 ms 2472 KB Output is correct
16 Correct 29 ms 2400 KB Output is correct
17 Correct 27 ms 2500 KB Output is correct
18 Correct 28 ms 2416 KB Output is correct
19 Correct 35 ms 2616 KB Output is correct
20 Correct 30 ms 2476 KB Output is correct
21 Correct 22 ms 2620 KB Output is correct
22 Correct 23 ms 2448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 328 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 704 KB Output is correct
9 Correct 13 ms 1096 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 9 ms 968 KB Output is correct
12 Correct 11 ms 1180 KB Output is correct
13 Correct 8 ms 1136 KB Output is correct
14 Correct 9 ms 1120 KB Output is correct
15 Correct 35 ms 2472 KB Output is correct
16 Correct 29 ms 2400 KB Output is correct
17 Correct 27 ms 2500 KB Output is correct
18 Correct 28 ms 2416 KB Output is correct
19 Correct 35 ms 2616 KB Output is correct
20 Correct 30 ms 2476 KB Output is correct
21 Correct 22 ms 2620 KB Output is correct
22 Correct 23 ms 2448 KB Output is correct
23 Correct 29 ms 2464 KB Output is correct
24 Correct 41 ms 2616 KB Output is correct
25 Correct 29 ms 2676 KB Output is correct
26 Correct 30 ms 2444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 328 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 704 KB Output is correct
9 Correct 13 ms 1096 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 9 ms 968 KB Output is correct
12 Correct 11 ms 1180 KB Output is correct
13 Correct 8 ms 1136 KB Output is correct
14 Correct 9 ms 1120 KB Output is correct
15 Correct 35 ms 2472 KB Output is correct
16 Correct 29 ms 2400 KB Output is correct
17 Correct 27 ms 2500 KB Output is correct
18 Correct 28 ms 2416 KB Output is correct
19 Correct 35 ms 2616 KB Output is correct
20 Correct 30 ms 2476 KB Output is correct
21 Correct 22 ms 2620 KB Output is correct
22 Correct 23 ms 2448 KB Output is correct
23 Correct 29 ms 2464 KB Output is correct
24 Correct 41 ms 2616 KB Output is correct
25 Correct 29 ms 2676 KB Output is correct
26 Correct 30 ms 2444 KB Output is correct
27 Incorrect 29 ms 2392 KB Wrong Answer [2]
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 328 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 704 KB Output is correct
9 Correct 13 ms 1096 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 9 ms 968 KB Output is correct
12 Correct 11 ms 1180 KB Output is correct
13 Correct 8 ms 1136 KB Output is correct
14 Correct 9 ms 1120 KB Output is correct
15 Correct 35 ms 2472 KB Output is correct
16 Correct 29 ms 2400 KB Output is correct
17 Correct 27 ms 2500 KB Output is correct
18 Correct 28 ms 2416 KB Output is correct
19 Correct 35 ms 2616 KB Output is correct
20 Correct 30 ms 2476 KB Output is correct
21 Correct 22 ms 2620 KB Output is correct
22 Correct 23 ms 2448 KB Output is correct
23 Correct 29 ms 2464 KB Output is correct
24 Correct 41 ms 2616 KB Output is correct
25 Correct 29 ms 2676 KB Output is correct
26 Correct 30 ms 2444 KB Output is correct
27 Incorrect 29 ms 2392 KB Wrong Answer [2]
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 328 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 704 KB Output is correct
9 Correct 13 ms 1096 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 9 ms 968 KB Output is correct
12 Correct 11 ms 1180 KB Output is correct
13 Correct 8 ms 1136 KB Output is correct
14 Correct 9 ms 1120 KB Output is correct
15 Correct 35 ms 2472 KB Output is correct
16 Correct 29 ms 2400 KB Output is correct
17 Correct 27 ms 2500 KB Output is correct
18 Correct 28 ms 2416 KB Output is correct
19 Correct 35 ms 2616 KB Output is correct
20 Correct 30 ms 2476 KB Output is correct
21 Correct 22 ms 2620 KB Output is correct
22 Correct 23 ms 2448 KB Output is correct
23 Correct 29 ms 2464 KB Output is correct
24 Correct 41 ms 2616 KB Output is correct
25 Correct 29 ms 2676 KB Output is correct
26 Correct 30 ms 2444 KB Output is correct
27 Incorrect 29 ms 2392 KB Wrong Answer [2]
28 Halted 0 ms 0 KB -