Submission #163302

# Submission time Handle Problem Language Result Execution time Memory
163302 2019-11-12T13:43:51 Z georgerapeanu Minerals (JOI19_minerals) C++14
100 / 100
90 ms 3060 KB
#include "minerals.h"

#pragma once
#include <vector>
#include <algorithm>

using namespace std;

bool my_query(int a) {
    static int last = 0;
    a = Query(a);
    int ans = a ^ last;
    last = a;
    return ans > 0;
}

void solve(const vector<int> &l,const vector<int> &r,bool mode) {
    if((int)l.size() == 1) {
        Answer(l[0],r[0]);
        return ;
    }

    int len = max(1,int(0.65 * (int)l.size()));

    if(mode == true) {
        for(int i = (int)l.size() - 1; i >= len; i--) {
            my_query(l[i]);
        }
    }
    else {
        len = (int)l.size() - len;
        for(int i = 0; i < len; i++) {
            my_query(l[i]);
        }
    }

    vector<int> v[2];

    for(auto it:r) {
        v[((int)v[0].size()) >= len || ((int)v[1].size() < (int)l.size() - len && my_query(it) == 1)].push_back(it);
    }

    vector<int> st[2];

    for(int i = 0; i < (int)l.size(); i++) {
        st[i >= len].push_back(l[i]);
    }

    solve(st[0],v[0],true);
    solve(st[1],v[1],false);

}

void Solve(int n) {
    vector<int> v[2];
    for(int i = 1; i <= 2 * n; i++) {
        v[my_query(i)].push_back(i);
    }
    solve(v[0],v[1],true);
}

Compilation message

minerals.cpp:3:9: warning: #pragma once in main file
 #pragma once
         ^~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 3 ms 248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 4 ms 504 KB Output is correct
3 Correct 7 ms 504 KB Output is correct
4 Correct 12 ms 888 KB Output is correct
5 Correct 23 ms 1192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 3 ms 248 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 4 ms 504 KB Output is correct
7 Correct 7 ms 504 KB Output is correct
8 Correct 12 ms 888 KB Output is correct
9 Correct 23 ms 1192 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 15 ms 932 KB Output is correct
12 Correct 23 ms 1316 KB Output is correct
13 Correct 19 ms 1336 KB Output is correct
14 Correct 17 ms 1188 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 3 ms 248 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 4 ms 504 KB Output is correct
7 Correct 7 ms 504 KB Output is correct
8 Correct 12 ms 888 KB Output is correct
9 Correct 23 ms 1192 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 15 ms 932 KB Output is correct
12 Correct 23 ms 1316 KB Output is correct
13 Correct 19 ms 1336 KB Output is correct
14 Correct 17 ms 1188 KB Output is correct
15 Correct 57 ms 2656 KB Output is correct
16 Correct 57 ms 2676 KB Output is correct
17 Correct 43 ms 2548 KB Output is correct
18 Correct 44 ms 2376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 3 ms 248 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 4 ms 504 KB Output is correct
7 Correct 7 ms 504 KB Output is correct
8 Correct 12 ms 888 KB Output is correct
9 Correct 23 ms 1192 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 15 ms 932 KB Output is correct
12 Correct 23 ms 1316 KB Output is correct
13 Correct 19 ms 1336 KB Output is correct
14 Correct 17 ms 1188 KB Output is correct
15 Correct 57 ms 2656 KB Output is correct
16 Correct 57 ms 2676 KB Output is correct
17 Correct 43 ms 2548 KB Output is correct
18 Correct 44 ms 2376 KB Output is correct
19 Correct 60 ms 2808 KB Output is correct
20 Correct 61 ms 2804 KB Output is correct
21 Correct 45 ms 2756 KB Output is correct
22 Correct 90 ms 2628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 3 ms 248 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 4 ms 504 KB Output is correct
7 Correct 7 ms 504 KB Output is correct
8 Correct 12 ms 888 KB Output is correct
9 Correct 23 ms 1192 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 15 ms 932 KB Output is correct
12 Correct 23 ms 1316 KB Output is correct
13 Correct 19 ms 1336 KB Output is correct
14 Correct 17 ms 1188 KB Output is correct
15 Correct 57 ms 2656 KB Output is correct
16 Correct 57 ms 2676 KB Output is correct
17 Correct 43 ms 2548 KB Output is correct
18 Correct 44 ms 2376 KB Output is correct
19 Correct 60 ms 2808 KB Output is correct
20 Correct 61 ms 2804 KB Output is correct
21 Correct 45 ms 2756 KB Output is correct
22 Correct 90 ms 2628 KB Output is correct
23 Correct 64 ms 2892 KB Output is correct
24 Correct 61 ms 2884 KB Output is correct
25 Correct 46 ms 2724 KB Output is correct
26 Correct 46 ms 2528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 3 ms 248 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 4 ms 504 KB Output is correct
7 Correct 7 ms 504 KB Output is correct
8 Correct 12 ms 888 KB Output is correct
9 Correct 23 ms 1192 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 15 ms 932 KB Output is correct
12 Correct 23 ms 1316 KB Output is correct
13 Correct 19 ms 1336 KB Output is correct
14 Correct 17 ms 1188 KB Output is correct
15 Correct 57 ms 2656 KB Output is correct
16 Correct 57 ms 2676 KB Output is correct
17 Correct 43 ms 2548 KB Output is correct
18 Correct 44 ms 2376 KB Output is correct
19 Correct 60 ms 2808 KB Output is correct
20 Correct 61 ms 2804 KB Output is correct
21 Correct 45 ms 2756 KB Output is correct
22 Correct 90 ms 2628 KB Output is correct
23 Correct 64 ms 2892 KB Output is correct
24 Correct 61 ms 2884 KB Output is correct
25 Correct 46 ms 2724 KB Output is correct
26 Correct 46 ms 2528 KB Output is correct
27 Correct 61 ms 2848 KB Output is correct
28 Correct 63 ms 2880 KB Output is correct
29 Correct 47 ms 2884 KB Output is correct
30 Correct 47 ms 2676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 3 ms 248 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 4 ms 504 KB Output is correct
7 Correct 7 ms 504 KB Output is correct
8 Correct 12 ms 888 KB Output is correct
9 Correct 23 ms 1192 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 15 ms 932 KB Output is correct
12 Correct 23 ms 1316 KB Output is correct
13 Correct 19 ms 1336 KB Output is correct
14 Correct 17 ms 1188 KB Output is correct
15 Correct 57 ms 2656 KB Output is correct
16 Correct 57 ms 2676 KB Output is correct
17 Correct 43 ms 2548 KB Output is correct
18 Correct 44 ms 2376 KB Output is correct
19 Correct 60 ms 2808 KB Output is correct
20 Correct 61 ms 2804 KB Output is correct
21 Correct 45 ms 2756 KB Output is correct
22 Correct 90 ms 2628 KB Output is correct
23 Correct 64 ms 2892 KB Output is correct
24 Correct 61 ms 2884 KB Output is correct
25 Correct 46 ms 2724 KB Output is correct
26 Correct 46 ms 2528 KB Output is correct
27 Correct 61 ms 2848 KB Output is correct
28 Correct 63 ms 2880 KB Output is correct
29 Correct 47 ms 2884 KB Output is correct
30 Correct 47 ms 2676 KB Output is correct
31 Correct 64 ms 2876 KB Output is correct
32 Correct 64 ms 2992 KB Output is correct
33 Correct 53 ms 2804 KB Output is correct
34 Correct 49 ms 2648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 3 ms 248 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 4 ms 504 KB Output is correct
7 Correct 7 ms 504 KB Output is correct
8 Correct 12 ms 888 KB Output is correct
9 Correct 23 ms 1192 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 15 ms 932 KB Output is correct
12 Correct 23 ms 1316 KB Output is correct
13 Correct 19 ms 1336 KB Output is correct
14 Correct 17 ms 1188 KB Output is correct
15 Correct 57 ms 2656 KB Output is correct
16 Correct 57 ms 2676 KB Output is correct
17 Correct 43 ms 2548 KB Output is correct
18 Correct 44 ms 2376 KB Output is correct
19 Correct 60 ms 2808 KB Output is correct
20 Correct 61 ms 2804 KB Output is correct
21 Correct 45 ms 2756 KB Output is correct
22 Correct 90 ms 2628 KB Output is correct
23 Correct 64 ms 2892 KB Output is correct
24 Correct 61 ms 2884 KB Output is correct
25 Correct 46 ms 2724 KB Output is correct
26 Correct 46 ms 2528 KB Output is correct
27 Correct 61 ms 2848 KB Output is correct
28 Correct 63 ms 2880 KB Output is correct
29 Correct 47 ms 2884 KB Output is correct
30 Correct 47 ms 2676 KB Output is correct
31 Correct 64 ms 2876 KB Output is correct
32 Correct 64 ms 2992 KB Output is correct
33 Correct 53 ms 2804 KB Output is correct
34 Correct 49 ms 2648 KB Output is correct
35 Correct 66 ms 3060 KB Output is correct
36 Correct 66 ms 2956 KB Output is correct
37 Correct 49 ms 3016 KB Output is correct
38 Correct 49 ms 2676 KB Output is correct