답안 #674939

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
674939 2022-12-26T16:15:55 Z urosk Minerals (JOI19_minerals) C++14
100 / 100
62 ms 4200 KB
#include "minerals.h"
#define here cerr<<"===========================================\n"
#define dbg(x) cerr<<#x<<": "<<x<<endl;
#include "bits/stdc++.h"
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
#define ld double
#define ll int
#define llinf 100000000000000000LL // 10^17
#define pb push_back
#define popb pop_back
#define fi first
#define sc second
#define endl '\n'
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define sz(a) (ll)(a.size())
#define all(a) a.begin(),a.end()
#define ceri(a,l,r) {cerr<<#a<<": ";for(ll i_ = l;i_<=r;i_++) cerr<<a[i_]<< " ";cerr<<endl;}
#define cer(a) {cerr<<#a<<": ";for(ll x_ : a) cerr<<x_<< " ";cerr<<endl;}

#define daj_mi_malo_vremena ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0);cin.tie(0);

using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll last = 0,n;
bool ask(ll i){
    ll cur = Query(i);
    bool ans = cur!=last;
    last = cur;
    return ans;
}
void reshi(vector<ll> l,vector<ll> r,bool f){
    n = sz(l);
    ll m = ceil(n*0.35);
    if(n==1){
        Answer(l[0],r[0]);
        return;
    }
    if(f) m = n-m;
    if(f){
        for(ll i = n-1;i>=m;i--) ask(l[i]);
    }else{
        for(ll i = 0;i<m;i++) ask(l[i]);
    }
    shuffle(all(r),rng);
    vector<ll> L,R;
    for(ll i = 0;i<n;i++){
        if(sz(L)==m) R.pb(r[i]);
        else if(sz(R)==n-m) L.pb(r[i]);
        else if(ask(r[i])) R.pb(r[i]);
        else L.pb(r[i]);
    }
    vector<ll> lL,lR;
    for(ll i = 0;i<m;i++) lL.pb(l[i]);
    for(ll i = m;i<n;i++) lR.pb(l[i]);
    reshi(lL,L,1);
    reshi(lR,R,0);
}
void Solve(int N) {
    n = N;
    vector<ll> l,r;
    for(ll i = 1;i<=2*n;i++){
        if(ask(i)) l.pb(i);
        else r.pb(i);
    }
    reshi(l,r,1);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 0 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 3 ms 500 KB Output is correct
3 Correct 6 ms 596 KB Output is correct
4 Correct 9 ms 1012 KB Output is correct
5 Correct 19 ms 1648 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 0 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 3 ms 500 KB Output is correct
7 Correct 6 ms 596 KB Output is correct
8 Correct 9 ms 1012 KB Output is correct
9 Correct 19 ms 1648 KB Output is correct
10 Correct 2 ms 336 KB Output is correct
11 Correct 12 ms 1236 KB Output is correct
12 Correct 19 ms 1616 KB Output is correct
13 Correct 20 ms 1688 KB Output is correct
14 Correct 18 ms 1616 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 0 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 3 ms 500 KB Output is correct
7 Correct 6 ms 596 KB Output is correct
8 Correct 9 ms 1012 KB Output is correct
9 Correct 19 ms 1648 KB Output is correct
10 Correct 2 ms 336 KB Output is correct
11 Correct 12 ms 1236 KB Output is correct
12 Correct 19 ms 1616 KB Output is correct
13 Correct 20 ms 1688 KB Output is correct
14 Correct 18 ms 1616 KB Output is correct
15 Correct 53 ms 3680 KB Output is correct
16 Correct 52 ms 3696 KB Output is correct
17 Correct 51 ms 3596 KB Output is correct
18 Correct 48 ms 3496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 0 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 3 ms 500 KB Output is correct
7 Correct 6 ms 596 KB Output is correct
8 Correct 9 ms 1012 KB Output is correct
9 Correct 19 ms 1648 KB Output is correct
10 Correct 2 ms 336 KB Output is correct
11 Correct 12 ms 1236 KB Output is correct
12 Correct 19 ms 1616 KB Output is correct
13 Correct 20 ms 1688 KB Output is correct
14 Correct 18 ms 1616 KB Output is correct
15 Correct 53 ms 3680 KB Output is correct
16 Correct 52 ms 3696 KB Output is correct
17 Correct 51 ms 3596 KB Output is correct
18 Correct 48 ms 3496 KB Output is correct
19 Correct 52 ms 3908 KB Output is correct
20 Correct 53 ms 3788 KB Output is correct
21 Correct 50 ms 3812 KB Output is correct
22 Correct 51 ms 3780 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 0 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 3 ms 500 KB Output is correct
7 Correct 6 ms 596 KB Output is correct
8 Correct 9 ms 1012 KB Output is correct
9 Correct 19 ms 1648 KB Output is correct
10 Correct 2 ms 336 KB Output is correct
11 Correct 12 ms 1236 KB Output is correct
12 Correct 19 ms 1616 KB Output is correct
13 Correct 20 ms 1688 KB Output is correct
14 Correct 18 ms 1616 KB Output is correct
15 Correct 53 ms 3680 KB Output is correct
16 Correct 52 ms 3696 KB Output is correct
17 Correct 51 ms 3596 KB Output is correct
18 Correct 48 ms 3496 KB Output is correct
19 Correct 52 ms 3908 KB Output is correct
20 Correct 53 ms 3788 KB Output is correct
21 Correct 50 ms 3812 KB Output is correct
22 Correct 51 ms 3780 KB Output is correct
23 Correct 61 ms 3804 KB Output is correct
24 Correct 55 ms 3840 KB Output is correct
25 Correct 52 ms 3908 KB Output is correct
26 Correct 59 ms 3732 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 0 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 3 ms 500 KB Output is correct
7 Correct 6 ms 596 KB Output is correct
8 Correct 9 ms 1012 KB Output is correct
9 Correct 19 ms 1648 KB Output is correct
10 Correct 2 ms 336 KB Output is correct
11 Correct 12 ms 1236 KB Output is correct
12 Correct 19 ms 1616 KB Output is correct
13 Correct 20 ms 1688 KB Output is correct
14 Correct 18 ms 1616 KB Output is correct
15 Correct 53 ms 3680 KB Output is correct
16 Correct 52 ms 3696 KB Output is correct
17 Correct 51 ms 3596 KB Output is correct
18 Correct 48 ms 3496 KB Output is correct
19 Correct 52 ms 3908 KB Output is correct
20 Correct 53 ms 3788 KB Output is correct
21 Correct 50 ms 3812 KB Output is correct
22 Correct 51 ms 3780 KB Output is correct
23 Correct 61 ms 3804 KB Output is correct
24 Correct 55 ms 3840 KB Output is correct
25 Correct 52 ms 3908 KB Output is correct
26 Correct 59 ms 3732 KB Output is correct
27 Correct 59 ms 4200 KB Output is correct
28 Correct 58 ms 3964 KB Output is correct
29 Correct 55 ms 3876 KB Output is correct
30 Correct 53 ms 3840 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 0 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 3 ms 500 KB Output is correct
7 Correct 6 ms 596 KB Output is correct
8 Correct 9 ms 1012 KB Output is correct
9 Correct 19 ms 1648 KB Output is correct
10 Correct 2 ms 336 KB Output is correct
11 Correct 12 ms 1236 KB Output is correct
12 Correct 19 ms 1616 KB Output is correct
13 Correct 20 ms 1688 KB Output is correct
14 Correct 18 ms 1616 KB Output is correct
15 Correct 53 ms 3680 KB Output is correct
16 Correct 52 ms 3696 KB Output is correct
17 Correct 51 ms 3596 KB Output is correct
18 Correct 48 ms 3496 KB Output is correct
19 Correct 52 ms 3908 KB Output is correct
20 Correct 53 ms 3788 KB Output is correct
21 Correct 50 ms 3812 KB Output is correct
22 Correct 51 ms 3780 KB Output is correct
23 Correct 61 ms 3804 KB Output is correct
24 Correct 55 ms 3840 KB Output is correct
25 Correct 52 ms 3908 KB Output is correct
26 Correct 59 ms 3732 KB Output is correct
27 Correct 59 ms 4200 KB Output is correct
28 Correct 58 ms 3964 KB Output is correct
29 Correct 55 ms 3876 KB Output is correct
30 Correct 53 ms 3840 KB Output is correct
31 Correct 62 ms 4036 KB Output is correct
32 Correct 59 ms 4044 KB Output is correct
33 Correct 56 ms 4068 KB Output is correct
34 Correct 60 ms 3888 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 0 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 3 ms 500 KB Output is correct
7 Correct 6 ms 596 KB Output is correct
8 Correct 9 ms 1012 KB Output is correct
9 Correct 19 ms 1648 KB Output is correct
10 Correct 2 ms 336 KB Output is correct
11 Correct 12 ms 1236 KB Output is correct
12 Correct 19 ms 1616 KB Output is correct
13 Correct 20 ms 1688 KB Output is correct
14 Correct 18 ms 1616 KB Output is correct
15 Correct 53 ms 3680 KB Output is correct
16 Correct 52 ms 3696 KB Output is correct
17 Correct 51 ms 3596 KB Output is correct
18 Correct 48 ms 3496 KB Output is correct
19 Correct 52 ms 3908 KB Output is correct
20 Correct 53 ms 3788 KB Output is correct
21 Correct 50 ms 3812 KB Output is correct
22 Correct 51 ms 3780 KB Output is correct
23 Correct 61 ms 3804 KB Output is correct
24 Correct 55 ms 3840 KB Output is correct
25 Correct 52 ms 3908 KB Output is correct
26 Correct 59 ms 3732 KB Output is correct
27 Correct 59 ms 4200 KB Output is correct
28 Correct 58 ms 3964 KB Output is correct
29 Correct 55 ms 3876 KB Output is correct
30 Correct 53 ms 3840 KB Output is correct
31 Correct 62 ms 4036 KB Output is correct
32 Correct 59 ms 4044 KB Output is correct
33 Correct 56 ms 4068 KB Output is correct
34 Correct 60 ms 3888 KB Output is correct
35 Correct 60 ms 4092 KB Output is correct
36 Correct 59 ms 4072 KB Output is correct
37 Correct 55 ms 4036 KB Output is correct
38 Correct 57 ms 3936 KB Output is correct