Submission #960579

# Submission time Handle Problem Language Result Execution time Memory
960579 2024-04-10T16:05:50 Z Tuanlinh123 Minerals (JOI19_minerals) C++17
100 / 100
33 ms 6024 KB
#include "minerals.h"
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define sz(a) ((ll)(a).size())
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

void Solve(int n) 
{
    ll crr=0;
    vector <ll> A, B, a(n*2+1, 0);
    auto flip=[&](ll idx)
    {
        ll x=Query(idx)-crr;
        crr+=x, a[idx]^=1; return x;
    };
    for (ll i=1; i<=n*2; i++) (flip(i)?A:B).pb(i);
    function <void(vector <ll>, vector <ll>, bool)> 
    solve=[&](vector <ll> L, vector <ll> R, bool cr)
    {
        ll n=sz(L);
        if (n==1) {Answer(L[0], R[0]); return;}
        vector <ll> left, right;
        ll len=max(1.0, 0.4*n);
        for (ll i=0; i<len; i++) flip(L[i]);
        for (ll i:R)
        {
            if (sz(left)==len) right.pb(i);
            else if (sz(right)==n-len) left.pb(i);
            else (a[i]^(a[i]+flip(i))^cr?right:left).pb(i);
        } 
        solve(vector <ll> (L.begin(), L.begin()+len), left, cr^1);
        solve(vector <ll> (L.begin()+len, L.end()), right, cr);
    }; solve(A, B, 1);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 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 600 KB Output is correct
3 Correct 3 ms 856 KB Output is correct
4 Correct 5 ms 1520 KB Output is correct
5 Correct 10 ms 2104 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 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 600 KB Output is correct
7 Correct 3 ms 856 KB Output is correct
8 Correct 5 ms 1520 KB Output is correct
9 Correct 10 ms 2104 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 6 ms 1624 KB Output is correct
12 Correct 10 ms 2352 KB Output is correct
13 Correct 11 ms 2796 KB Output is correct
14 Correct 7 ms 2292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 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 600 KB Output is correct
7 Correct 3 ms 856 KB Output is correct
8 Correct 5 ms 1520 KB Output is correct
9 Correct 10 ms 2104 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 6 ms 1624 KB Output is correct
12 Correct 10 ms 2352 KB Output is correct
13 Correct 11 ms 2796 KB Output is correct
14 Correct 7 ms 2292 KB Output is correct
15 Correct 27 ms 5076 KB Output is correct
16 Correct 26 ms 5080 KB Output is correct
17 Correct 18 ms 5408 KB Output is correct
18 Correct 19 ms 5372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 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 600 KB Output is correct
7 Correct 3 ms 856 KB Output is correct
8 Correct 5 ms 1520 KB Output is correct
9 Correct 10 ms 2104 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 6 ms 1624 KB Output is correct
12 Correct 10 ms 2352 KB Output is correct
13 Correct 11 ms 2796 KB Output is correct
14 Correct 7 ms 2292 KB Output is correct
15 Correct 27 ms 5076 KB Output is correct
16 Correct 26 ms 5080 KB Output is correct
17 Correct 18 ms 5408 KB Output is correct
18 Correct 19 ms 5372 KB Output is correct
19 Correct 26 ms 5376 KB Output is correct
20 Correct 27 ms 5168 KB Output is correct
21 Correct 21 ms 5708 KB Output is correct
22 Correct 19 ms 5308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 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 600 KB Output is correct
7 Correct 3 ms 856 KB Output is correct
8 Correct 5 ms 1520 KB Output is correct
9 Correct 10 ms 2104 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 6 ms 1624 KB Output is correct
12 Correct 10 ms 2352 KB Output is correct
13 Correct 11 ms 2796 KB Output is correct
14 Correct 7 ms 2292 KB Output is correct
15 Correct 27 ms 5076 KB Output is correct
16 Correct 26 ms 5080 KB Output is correct
17 Correct 18 ms 5408 KB Output is correct
18 Correct 19 ms 5372 KB Output is correct
19 Correct 26 ms 5376 KB Output is correct
20 Correct 27 ms 5168 KB Output is correct
21 Correct 21 ms 5708 KB Output is correct
22 Correct 19 ms 5308 KB Output is correct
23 Correct 28 ms 5352 KB Output is correct
24 Correct 29 ms 5364 KB Output is correct
25 Correct 25 ms 5452 KB Output is correct
26 Correct 20 ms 5204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 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 600 KB Output is correct
7 Correct 3 ms 856 KB Output is correct
8 Correct 5 ms 1520 KB Output is correct
9 Correct 10 ms 2104 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 6 ms 1624 KB Output is correct
12 Correct 10 ms 2352 KB Output is correct
13 Correct 11 ms 2796 KB Output is correct
14 Correct 7 ms 2292 KB Output is correct
15 Correct 27 ms 5076 KB Output is correct
16 Correct 26 ms 5080 KB Output is correct
17 Correct 18 ms 5408 KB Output is correct
18 Correct 19 ms 5372 KB Output is correct
19 Correct 26 ms 5376 KB Output is correct
20 Correct 27 ms 5168 KB Output is correct
21 Correct 21 ms 5708 KB Output is correct
22 Correct 19 ms 5308 KB Output is correct
23 Correct 28 ms 5352 KB Output is correct
24 Correct 29 ms 5364 KB Output is correct
25 Correct 25 ms 5452 KB Output is correct
26 Correct 20 ms 5204 KB Output is correct
27 Correct 33 ms 5368 KB Output is correct
28 Correct 33 ms 5472 KB Output is correct
29 Correct 20 ms 5740 KB Output is correct
30 Correct 21 ms 5692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 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 600 KB Output is correct
7 Correct 3 ms 856 KB Output is correct
8 Correct 5 ms 1520 KB Output is correct
9 Correct 10 ms 2104 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 6 ms 1624 KB Output is correct
12 Correct 10 ms 2352 KB Output is correct
13 Correct 11 ms 2796 KB Output is correct
14 Correct 7 ms 2292 KB Output is correct
15 Correct 27 ms 5076 KB Output is correct
16 Correct 26 ms 5080 KB Output is correct
17 Correct 18 ms 5408 KB Output is correct
18 Correct 19 ms 5372 KB Output is correct
19 Correct 26 ms 5376 KB Output is correct
20 Correct 27 ms 5168 KB Output is correct
21 Correct 21 ms 5708 KB Output is correct
22 Correct 19 ms 5308 KB Output is correct
23 Correct 28 ms 5352 KB Output is correct
24 Correct 29 ms 5364 KB Output is correct
25 Correct 25 ms 5452 KB Output is correct
26 Correct 20 ms 5204 KB Output is correct
27 Correct 33 ms 5368 KB Output is correct
28 Correct 33 ms 5472 KB Output is correct
29 Correct 20 ms 5740 KB Output is correct
30 Correct 21 ms 5692 KB Output is correct
31 Correct 29 ms 5628 KB Output is correct
32 Correct 28 ms 5672 KB Output is correct
33 Correct 23 ms 6024 KB Output is correct
34 Correct 27 ms 5652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 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 600 KB Output is correct
7 Correct 3 ms 856 KB Output is correct
8 Correct 5 ms 1520 KB Output is correct
9 Correct 10 ms 2104 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 6 ms 1624 KB Output is correct
12 Correct 10 ms 2352 KB Output is correct
13 Correct 11 ms 2796 KB Output is correct
14 Correct 7 ms 2292 KB Output is correct
15 Correct 27 ms 5076 KB Output is correct
16 Correct 26 ms 5080 KB Output is correct
17 Correct 18 ms 5408 KB Output is correct
18 Correct 19 ms 5372 KB Output is correct
19 Correct 26 ms 5376 KB Output is correct
20 Correct 27 ms 5168 KB Output is correct
21 Correct 21 ms 5708 KB Output is correct
22 Correct 19 ms 5308 KB Output is correct
23 Correct 28 ms 5352 KB Output is correct
24 Correct 29 ms 5364 KB Output is correct
25 Correct 25 ms 5452 KB Output is correct
26 Correct 20 ms 5204 KB Output is correct
27 Correct 33 ms 5368 KB Output is correct
28 Correct 33 ms 5472 KB Output is correct
29 Correct 20 ms 5740 KB Output is correct
30 Correct 21 ms 5692 KB Output is correct
31 Correct 29 ms 5628 KB Output is correct
32 Correct 28 ms 5672 KB Output is correct
33 Correct 23 ms 6024 KB Output is correct
34 Correct 27 ms 5652 KB Output is correct
35 Correct 29 ms 5672 KB Output is correct
36 Correct 32 ms 5784 KB Output is correct
37 Correct 21 ms 5920 KB Output is correct
38 Correct 28 ms 5492 KB Output is correct