Submission #477670

# Submission time Handle Problem Language Result Execution time Memory
477670 2021-10-03T02:56:57 Z HappyPacMan Minerals (JOI19_minerals) C++14
100 / 100
88 ms 3028 KB
#include "minerals.h"
#include <bits/stdc++.h>
using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int curr = 0;

bool change(int u){
    int nxt = Query(u);
    bool res = (nxt != curr);
    curr = nxt;
    return res;
}

void rec(vector<int> &A,vector<int> &B,bool rev){
    int len = A.size();
    if(len == 1){
        Answer(A[0],B[0]);
        return;
    }
    shuffle(A.begin(),A.end(),rng);
    shuffle(B.begin(),B.end(),rng);
    int mid = (rev?382:618)*len/1000;
    if(mid == 0) mid++;
    if(mid == len) mid--;
    vector<int> nA[2],nB[2];
    for(int i=0;i<len;i++){
        if(i < mid) nA[0].push_back(A[i]);
        else nA[1].push_back(A[i]);
        if((mid <= i) ^ rev) change(A[i]);
    }
    for(int i=0;i<len;i++){
        if(nB[0].size() == nA[0].size()) nB[1].push_back(B[i]);
        else if(nB[1].size() == nA[1].size()) nB[0].push_back(B[i]);
        else if(change(B[i])) nB[0].push_back(B[i]);
        else nB[1].push_back(B[i]);
    }
    rec(nA[0],nB[0],0);
    rec(nA[1],nB[1],1);
}

void Solve(int N){
    vector<int> group[2];
    for(int i=1;i<=2*N;i++) group[change(i)].push_back(i);
    rec(group[0],group[1],1);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 328 KB Output is correct
2 Correct 3 ms 424 KB Output is correct
3 Correct 6 ms 540 KB Output is correct
4 Correct 12 ms 768 KB Output is correct
5 Correct 24 ms 1200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 2 ms 328 KB Output is correct
6 Correct 3 ms 424 KB Output is correct
7 Correct 6 ms 540 KB Output is correct
8 Correct 12 ms 768 KB Output is correct
9 Correct 24 ms 1200 KB Output is correct
10 Correct 3 ms 328 KB Output is correct
11 Correct 16 ms 924 KB Output is correct
12 Correct 23 ms 1224 KB Output is correct
13 Correct 25 ms 1200 KB Output is correct
14 Correct 24 ms 1196 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 2 ms 328 KB Output is correct
6 Correct 3 ms 424 KB Output is correct
7 Correct 6 ms 540 KB Output is correct
8 Correct 12 ms 768 KB Output is correct
9 Correct 24 ms 1200 KB Output is correct
10 Correct 3 ms 328 KB Output is correct
11 Correct 16 ms 924 KB Output is correct
12 Correct 23 ms 1224 KB Output is correct
13 Correct 25 ms 1200 KB Output is correct
14 Correct 24 ms 1196 KB Output is correct
15 Correct 88 ms 2764 KB Output is correct
16 Correct 77 ms 2780 KB Output is correct
17 Correct 65 ms 2748 KB Output is correct
18 Correct 65 ms 2512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 2 ms 328 KB Output is correct
6 Correct 3 ms 424 KB Output is correct
7 Correct 6 ms 540 KB Output is correct
8 Correct 12 ms 768 KB Output is correct
9 Correct 24 ms 1200 KB Output is correct
10 Correct 3 ms 328 KB Output is correct
11 Correct 16 ms 924 KB Output is correct
12 Correct 23 ms 1224 KB Output is correct
13 Correct 25 ms 1200 KB Output is correct
14 Correct 24 ms 1196 KB Output is correct
15 Correct 88 ms 2764 KB Output is correct
16 Correct 77 ms 2780 KB Output is correct
17 Correct 65 ms 2748 KB Output is correct
18 Correct 65 ms 2512 KB Output is correct
19 Correct 83 ms 2800 KB Output is correct
20 Correct 76 ms 2800 KB Output is correct
21 Correct 69 ms 2868 KB Output is correct
22 Correct 67 ms 2672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 2 ms 328 KB Output is correct
6 Correct 3 ms 424 KB Output is correct
7 Correct 6 ms 540 KB Output is correct
8 Correct 12 ms 768 KB Output is correct
9 Correct 24 ms 1200 KB Output is correct
10 Correct 3 ms 328 KB Output is correct
11 Correct 16 ms 924 KB Output is correct
12 Correct 23 ms 1224 KB Output is correct
13 Correct 25 ms 1200 KB Output is correct
14 Correct 24 ms 1196 KB Output is correct
15 Correct 88 ms 2764 KB Output is correct
16 Correct 77 ms 2780 KB Output is correct
17 Correct 65 ms 2748 KB Output is correct
18 Correct 65 ms 2512 KB Output is correct
19 Correct 83 ms 2800 KB Output is correct
20 Correct 76 ms 2800 KB Output is correct
21 Correct 69 ms 2868 KB Output is correct
22 Correct 67 ms 2672 KB Output is correct
23 Correct 84 ms 2852 KB Output is correct
24 Correct 72 ms 2776 KB Output is correct
25 Correct 72 ms 2804 KB Output is correct
26 Correct 70 ms 2624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 2 ms 328 KB Output is correct
6 Correct 3 ms 424 KB Output is correct
7 Correct 6 ms 540 KB Output is correct
8 Correct 12 ms 768 KB Output is correct
9 Correct 24 ms 1200 KB Output is correct
10 Correct 3 ms 328 KB Output is correct
11 Correct 16 ms 924 KB Output is correct
12 Correct 23 ms 1224 KB Output is correct
13 Correct 25 ms 1200 KB Output is correct
14 Correct 24 ms 1196 KB Output is correct
15 Correct 88 ms 2764 KB Output is correct
16 Correct 77 ms 2780 KB Output is correct
17 Correct 65 ms 2748 KB Output is correct
18 Correct 65 ms 2512 KB Output is correct
19 Correct 83 ms 2800 KB Output is correct
20 Correct 76 ms 2800 KB Output is correct
21 Correct 69 ms 2868 KB Output is correct
22 Correct 67 ms 2672 KB Output is correct
23 Correct 84 ms 2852 KB Output is correct
24 Correct 72 ms 2776 KB Output is correct
25 Correct 72 ms 2804 KB Output is correct
26 Correct 70 ms 2624 KB Output is correct
27 Correct 80 ms 2920 KB Output is correct
28 Correct 82 ms 2912 KB Output is correct
29 Correct 72 ms 2908 KB Output is correct
30 Correct 71 ms 2852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 2 ms 328 KB Output is correct
6 Correct 3 ms 424 KB Output is correct
7 Correct 6 ms 540 KB Output is correct
8 Correct 12 ms 768 KB Output is correct
9 Correct 24 ms 1200 KB Output is correct
10 Correct 3 ms 328 KB Output is correct
11 Correct 16 ms 924 KB Output is correct
12 Correct 23 ms 1224 KB Output is correct
13 Correct 25 ms 1200 KB Output is correct
14 Correct 24 ms 1196 KB Output is correct
15 Correct 88 ms 2764 KB Output is correct
16 Correct 77 ms 2780 KB Output is correct
17 Correct 65 ms 2748 KB Output is correct
18 Correct 65 ms 2512 KB Output is correct
19 Correct 83 ms 2800 KB Output is correct
20 Correct 76 ms 2800 KB Output is correct
21 Correct 69 ms 2868 KB Output is correct
22 Correct 67 ms 2672 KB Output is correct
23 Correct 84 ms 2852 KB Output is correct
24 Correct 72 ms 2776 KB Output is correct
25 Correct 72 ms 2804 KB Output is correct
26 Correct 70 ms 2624 KB Output is correct
27 Correct 80 ms 2920 KB Output is correct
28 Correct 82 ms 2912 KB Output is correct
29 Correct 72 ms 2908 KB Output is correct
30 Correct 71 ms 2852 KB Output is correct
31 Correct 73 ms 2924 KB Output is correct
32 Correct 81 ms 2908 KB Output is correct
33 Correct 84 ms 2996 KB Output is correct
34 Correct 74 ms 2796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 2 ms 328 KB Output is correct
6 Correct 3 ms 424 KB Output is correct
7 Correct 6 ms 540 KB Output is correct
8 Correct 12 ms 768 KB Output is correct
9 Correct 24 ms 1200 KB Output is correct
10 Correct 3 ms 328 KB Output is correct
11 Correct 16 ms 924 KB Output is correct
12 Correct 23 ms 1224 KB Output is correct
13 Correct 25 ms 1200 KB Output is correct
14 Correct 24 ms 1196 KB Output is correct
15 Correct 88 ms 2764 KB Output is correct
16 Correct 77 ms 2780 KB Output is correct
17 Correct 65 ms 2748 KB Output is correct
18 Correct 65 ms 2512 KB Output is correct
19 Correct 83 ms 2800 KB Output is correct
20 Correct 76 ms 2800 KB Output is correct
21 Correct 69 ms 2868 KB Output is correct
22 Correct 67 ms 2672 KB Output is correct
23 Correct 84 ms 2852 KB Output is correct
24 Correct 72 ms 2776 KB Output is correct
25 Correct 72 ms 2804 KB Output is correct
26 Correct 70 ms 2624 KB Output is correct
27 Correct 80 ms 2920 KB Output is correct
28 Correct 82 ms 2912 KB Output is correct
29 Correct 72 ms 2908 KB Output is correct
30 Correct 71 ms 2852 KB Output is correct
31 Correct 73 ms 2924 KB Output is correct
32 Correct 81 ms 2908 KB Output is correct
33 Correct 84 ms 2996 KB Output is correct
34 Correct 74 ms 2796 KB Output is correct
35 Correct 77 ms 3028 KB Output is correct
36 Correct 84 ms 2972 KB Output is correct
37 Correct 77 ms 3000 KB Output is correct
38 Correct 86 ms 2880 KB Output is correct