Submission #980877

# Submission time Handle Problem Language Result Execution time Memory
980877 2024-05-12T14:15:15 Z Jarif_Rahman Minerals (JOI19_minerals) C++17
90 / 100
43 ms 3600 KB
#include "minerals.h"
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int cnt = 0;
vector<int> ex, sth;

void pbs(int l, int r, bool right, bool reset, vector<int> X){
    if(X.empty()) return;
    if(l == r){
        for(int i: X) Answer(i, ex[l]);
        return;
    }

    int md = (l+r)/2;
    if(right) for(int i = l; i <= md; i++) cnt = Query(ex[i]);
    else for(int i = r; i > md; i--) cnt = Query(ex[i]);
    vector<int> A, B;
    shuffle(X.begin(), X.end(), rng);
    for(int i: X){
        if(A.size() == md-l+1){
            B.push_back(i);
            continue;
        }
        if(B.size() == r-md){
            A.push_back(i);
            continue;
        }
        if(md >= sth[i]){
            A.push_back(i);
            continue;
        }
        int cnt_ = Query(i);
        if(cnt_ == cnt) A.push_back(i);
        else B.push_back(i);
        cnt = cnt_;
    }

    pbs(l, md, 0, 1, A);
    pbs(md+1, r, 1, reset, B);
}

void Solve(int n){
    vector<int> o;
    for(int i = 1; i <= 2*n; i++) o.push_back(i);
    shuffle(o.begin(), o.end(), rng);

    vector<int> X;
    sth.resize(2*n);
    for(int i: o){
        int cnt_ = Query(i);
        if(cnt_ == cnt) X.push_back(i), sth[i] = ex.size();
        else ex.push_back(i);
        cnt = cnt_;
    }
    pbs(0, n-1, 0, 0, X);
}

Compilation message

minerals.cpp: In function 'void pbs(int, int, bool, bool, std::vector<int>)':
minerals.cpp:27:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   27 |         if(A.size() == md-l+1){
      |            ~~~~~~~~~^~~~~~~~~
minerals.cpp:31:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   31 |         if(B.size() == r-md){
      |            ~~~~~~~~~^~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 2 ms 456 KB Output is correct
3 Correct 3 ms 720 KB Output is correct
4 Correct 6 ms 856 KB Output is correct
5 Correct 12 ms 1368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 2 ms 456 KB Output is correct
7 Correct 3 ms 720 KB Output is correct
8 Correct 6 ms 856 KB Output is correct
9 Correct 12 ms 1368 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 8 ms 1040 KB Output is correct
12 Correct 12 ms 1368 KB Output is correct
13 Correct 12 ms 1784 KB Output is correct
14 Correct 12 ms 1372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 2 ms 456 KB Output is correct
7 Correct 3 ms 720 KB Output is correct
8 Correct 6 ms 856 KB Output is correct
9 Correct 12 ms 1368 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 8 ms 1040 KB Output is correct
12 Correct 12 ms 1368 KB Output is correct
13 Correct 12 ms 1784 KB Output is correct
14 Correct 12 ms 1372 KB Output is correct
15 Correct 36 ms 3160 KB Output is correct
16 Correct 35 ms 3160 KB Output is correct
17 Correct 36 ms 3460 KB Output is correct
18 Correct 33 ms 3148 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 2 ms 456 KB Output is correct
7 Correct 3 ms 720 KB Output is correct
8 Correct 6 ms 856 KB Output is correct
9 Correct 12 ms 1368 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 8 ms 1040 KB Output is correct
12 Correct 12 ms 1368 KB Output is correct
13 Correct 12 ms 1784 KB Output is correct
14 Correct 12 ms 1372 KB Output is correct
15 Correct 36 ms 3160 KB Output is correct
16 Correct 35 ms 3160 KB Output is correct
17 Correct 36 ms 3460 KB Output is correct
18 Correct 33 ms 3148 KB Output is correct
19 Correct 36 ms 3172 KB Output is correct
20 Correct 36 ms 3280 KB Output is correct
21 Correct 34 ms 3328 KB Output is correct
22 Correct 34 ms 3276 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 2 ms 456 KB Output is correct
7 Correct 3 ms 720 KB Output is correct
8 Correct 6 ms 856 KB Output is correct
9 Correct 12 ms 1368 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 8 ms 1040 KB Output is correct
12 Correct 12 ms 1368 KB Output is correct
13 Correct 12 ms 1784 KB Output is correct
14 Correct 12 ms 1372 KB Output is correct
15 Correct 36 ms 3160 KB Output is correct
16 Correct 35 ms 3160 KB Output is correct
17 Correct 36 ms 3460 KB Output is correct
18 Correct 33 ms 3148 KB Output is correct
19 Correct 36 ms 3172 KB Output is correct
20 Correct 36 ms 3280 KB Output is correct
21 Correct 34 ms 3328 KB Output is correct
22 Correct 34 ms 3276 KB Output is correct
23 Correct 36 ms 3168 KB Output is correct
24 Correct 43 ms 3176 KB Output is correct
25 Correct 35 ms 3308 KB Output is correct
26 Correct 37 ms 3220 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 2 ms 456 KB Output is correct
7 Correct 3 ms 720 KB Output is correct
8 Correct 6 ms 856 KB Output is correct
9 Correct 12 ms 1368 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 8 ms 1040 KB Output is correct
12 Correct 12 ms 1368 KB Output is correct
13 Correct 12 ms 1784 KB Output is correct
14 Correct 12 ms 1372 KB Output is correct
15 Correct 36 ms 3160 KB Output is correct
16 Correct 35 ms 3160 KB Output is correct
17 Correct 36 ms 3460 KB Output is correct
18 Correct 33 ms 3148 KB Output is correct
19 Correct 36 ms 3172 KB Output is correct
20 Correct 36 ms 3280 KB Output is correct
21 Correct 34 ms 3328 KB Output is correct
22 Correct 34 ms 3276 KB Output is correct
23 Correct 36 ms 3168 KB Output is correct
24 Correct 43 ms 3176 KB Output is correct
25 Correct 35 ms 3308 KB Output is correct
26 Correct 37 ms 3220 KB Output is correct
27 Correct 38 ms 3184 KB Output is correct
28 Correct 39 ms 3188 KB Output is correct
29 Correct 42 ms 3456 KB Output is correct
30 Correct 36 ms 3456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 2 ms 456 KB Output is correct
7 Correct 3 ms 720 KB Output is correct
8 Correct 6 ms 856 KB Output is correct
9 Correct 12 ms 1368 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 8 ms 1040 KB Output is correct
12 Correct 12 ms 1368 KB Output is correct
13 Correct 12 ms 1784 KB Output is correct
14 Correct 12 ms 1372 KB Output is correct
15 Correct 36 ms 3160 KB Output is correct
16 Correct 35 ms 3160 KB Output is correct
17 Correct 36 ms 3460 KB Output is correct
18 Correct 33 ms 3148 KB Output is correct
19 Correct 36 ms 3172 KB Output is correct
20 Correct 36 ms 3280 KB Output is correct
21 Correct 34 ms 3328 KB Output is correct
22 Correct 34 ms 3276 KB Output is correct
23 Correct 36 ms 3168 KB Output is correct
24 Correct 43 ms 3176 KB Output is correct
25 Correct 35 ms 3308 KB Output is correct
26 Correct 37 ms 3220 KB Output is correct
27 Correct 38 ms 3184 KB Output is correct
28 Correct 39 ms 3188 KB Output is correct
29 Correct 42 ms 3456 KB Output is correct
30 Correct 36 ms 3456 KB Output is correct
31 Correct 38 ms 3288 KB Output is correct
32 Correct 38 ms 3500 KB Output is correct
33 Correct 43 ms 3600 KB Output is correct
34 Correct 37 ms 3288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 2 ms 456 KB Output is correct
7 Correct 3 ms 720 KB Output is correct
8 Correct 6 ms 856 KB Output is correct
9 Correct 12 ms 1368 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 8 ms 1040 KB Output is correct
12 Correct 12 ms 1368 KB Output is correct
13 Correct 12 ms 1784 KB Output is correct
14 Correct 12 ms 1372 KB Output is correct
15 Correct 36 ms 3160 KB Output is correct
16 Correct 35 ms 3160 KB Output is correct
17 Correct 36 ms 3460 KB Output is correct
18 Correct 33 ms 3148 KB Output is correct
19 Correct 36 ms 3172 KB Output is correct
20 Correct 36 ms 3280 KB Output is correct
21 Correct 34 ms 3328 KB Output is correct
22 Correct 34 ms 3276 KB Output is correct
23 Correct 36 ms 3168 KB Output is correct
24 Correct 43 ms 3176 KB Output is correct
25 Correct 35 ms 3308 KB Output is correct
26 Correct 37 ms 3220 KB Output is correct
27 Correct 38 ms 3184 KB Output is correct
28 Correct 39 ms 3188 KB Output is correct
29 Correct 42 ms 3456 KB Output is correct
30 Correct 36 ms 3456 KB Output is correct
31 Correct 38 ms 3288 KB Output is correct
32 Correct 38 ms 3500 KB Output is correct
33 Correct 43 ms 3600 KB Output is correct
34 Correct 37 ms 3288 KB Output is correct
35 Incorrect 39 ms 3440 KB Wrong Answer [2]
36 Halted 0 ms 0 KB -