Submission #501632

# Submission time Handle Problem Language Result Execution time Memory
501632 2022-01-04T08:53:15 Z 79brue Minerals (JOI19_minerals) C++14
80 / 100
37 ms 2644 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]]);
}

Compilation message

minerals.cpp: In function 'void solve(int, int, std::vector<int>&)':
minerals.cpp:28:9: warning: unused variable 'tmpCalc' [-Wunused-variable]
   28 |     int tmpCalc = 0;
      |         ^~~~~~~
# 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 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 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 12 ms 1116 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 200 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 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 12 ms 1116 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 7 ms 892 KB Output is correct
12 Correct 10 ms 1096 KB Output is correct
13 Correct 9 ms 1176 KB Output is correct
14 Correct 9 ms 1024 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 200 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 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 12 ms 1116 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 7 ms 892 KB Output is correct
12 Correct 10 ms 1096 KB Output is correct
13 Correct 9 ms 1176 KB Output is correct
14 Correct 9 ms 1024 KB Output is correct
15 Correct 31 ms 2480 KB Output is correct
16 Correct 31 ms 2444 KB Output is correct
17 Correct 26 ms 2624 KB Output is correct
18 Correct 22 ms 2376 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 200 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 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 12 ms 1116 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 7 ms 892 KB Output is correct
12 Correct 10 ms 1096 KB Output is correct
13 Correct 9 ms 1176 KB Output is correct
14 Correct 9 ms 1024 KB Output is correct
15 Correct 31 ms 2480 KB Output is correct
16 Correct 31 ms 2444 KB Output is correct
17 Correct 26 ms 2624 KB Output is correct
18 Correct 22 ms 2376 KB Output is correct
19 Correct 29 ms 2456 KB Output is correct
20 Correct 31 ms 2540 KB Output is correct
21 Correct 22 ms 2560 KB Output is correct
22 Correct 30 ms 2396 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 200 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 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 12 ms 1116 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 7 ms 892 KB Output is correct
12 Correct 10 ms 1096 KB Output is correct
13 Correct 9 ms 1176 KB Output is correct
14 Correct 9 ms 1024 KB Output is correct
15 Correct 31 ms 2480 KB Output is correct
16 Correct 31 ms 2444 KB Output is correct
17 Correct 26 ms 2624 KB Output is correct
18 Correct 22 ms 2376 KB Output is correct
19 Correct 29 ms 2456 KB Output is correct
20 Correct 31 ms 2540 KB Output is correct
21 Correct 22 ms 2560 KB Output is correct
22 Correct 30 ms 2396 KB Output is correct
23 Correct 37 ms 2584 KB Output is correct
24 Correct 30 ms 2616 KB Output is correct
25 Correct 23 ms 2644 KB Output is correct
26 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 200 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 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 12 ms 1116 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 7 ms 892 KB Output is correct
12 Correct 10 ms 1096 KB Output is correct
13 Correct 9 ms 1176 KB Output is correct
14 Correct 9 ms 1024 KB Output is correct
15 Correct 31 ms 2480 KB Output is correct
16 Correct 31 ms 2444 KB Output is correct
17 Correct 26 ms 2624 KB Output is correct
18 Correct 22 ms 2376 KB Output is correct
19 Correct 29 ms 2456 KB Output is correct
20 Correct 31 ms 2540 KB Output is correct
21 Correct 22 ms 2560 KB Output is correct
22 Correct 30 ms 2396 KB Output is correct
23 Correct 37 ms 2584 KB Output is correct
24 Correct 30 ms 2616 KB Output is correct
25 Correct 23 ms 2644 KB Output is correct
26 Correct 23 ms 2480 KB Output is correct
27 Incorrect 30 ms 2504 KB Wrong Answer [2]
28 Halted 0 ms 0 KB -
# 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 200 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 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 12 ms 1116 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 7 ms 892 KB Output is correct
12 Correct 10 ms 1096 KB Output is correct
13 Correct 9 ms 1176 KB Output is correct
14 Correct 9 ms 1024 KB Output is correct
15 Correct 31 ms 2480 KB Output is correct
16 Correct 31 ms 2444 KB Output is correct
17 Correct 26 ms 2624 KB Output is correct
18 Correct 22 ms 2376 KB Output is correct
19 Correct 29 ms 2456 KB Output is correct
20 Correct 31 ms 2540 KB Output is correct
21 Correct 22 ms 2560 KB Output is correct
22 Correct 30 ms 2396 KB Output is correct
23 Correct 37 ms 2584 KB Output is correct
24 Correct 30 ms 2616 KB Output is correct
25 Correct 23 ms 2644 KB Output is correct
26 Correct 23 ms 2480 KB Output is correct
27 Incorrect 30 ms 2504 KB Wrong Answer [2]
28 Halted 0 ms 0 KB -
# 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 200 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 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 12 ms 1116 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 7 ms 892 KB Output is correct
12 Correct 10 ms 1096 KB Output is correct
13 Correct 9 ms 1176 KB Output is correct
14 Correct 9 ms 1024 KB Output is correct
15 Correct 31 ms 2480 KB Output is correct
16 Correct 31 ms 2444 KB Output is correct
17 Correct 26 ms 2624 KB Output is correct
18 Correct 22 ms 2376 KB Output is correct
19 Correct 29 ms 2456 KB Output is correct
20 Correct 31 ms 2540 KB Output is correct
21 Correct 22 ms 2560 KB Output is correct
22 Correct 30 ms 2396 KB Output is correct
23 Correct 37 ms 2584 KB Output is correct
24 Correct 30 ms 2616 KB Output is correct
25 Correct 23 ms 2644 KB Output is correct
26 Correct 23 ms 2480 KB Output is correct
27 Incorrect 30 ms 2504 KB Wrong Answer [2]
28 Halted 0 ms 0 KB -