Submission #922416

# Submission time Handle Problem Language Result Execution time Memory
922416 2024-02-05T13:40:04 Z HuyQuang_re_Zero The Big Prize (IOI17_prize) C++14
100 / 100
27 ms 3588 KB
#include <bits/stdc++.h>
#define ll long long
#define db long double
#define N 200005
#define II pair <ll,ll>
#define III pair <ll,II>
#define IV pair <vector <int>,vector <int> >
#define IDB pair <db,int>
#define TII pair <treap*,treap*>
#define fst first
#define snd second
#define BIT(x,i) ((x>>i)&1)
#define pi acos(-1)
#define to_radian(x) (x*pi/180.0)
#define to_degree(x) (x*180.0/pi)
#define Log(x) (31-__builtin_clz((int)x))
#define LogLL(x) (63-__builtin_clzll((ll)x)
using namespace std;
#include "prize.h"
struct Interactive
{
    int a[N],n;
    void Init(int _n)
    {
        n=_n;
        for(int i=0;i<n;i++) cin>>a[i];
    }
    vector <int> ask(int u)
    {
        vector <int> res; res.resize(2);
        for(int i=0;i<u;i++) res[0]+=(a[i]<a[u]);
        for(int i=u+1;i<n;i++) res[1]+=(a[i]<a[u]);
        return res;
    }
} IR;
//vector <int> ask(int u) { return IR.ask(u); }

int Before[N],After[N];
void quest(int u)
{
    vector <int> vec=ask(u);
    Before[u]=vec[0]; After[u]=vec[1];
}
bool Is_Diamond(int u)
{
    return Before[u]+After[u]==0;
}
int Find_Diamond(int l,int r)
{
    if(r-l<=1) return -1;
    if(Before[l]+After[l]==Before[r]+After[r])
    {
        if(Before[r]==Before[l]) return -1;
        int mid=(l+r)>>1;
        quest(mid);
        if(Is_Diamond(mid)) return mid;
        int k=Find_Diamond(l,mid);
        if(k>-1) return k;
        return Find_Diamond(mid,r);
    }
    else if(Before[l]+After[l]<Before[r]+After[r])
    {
        quest(l+1);
        if(Is_Diamond(l+1)) return l+1;
        return Find_Diamond(l+1,r);
    }
    else
    {
        quest(r-1);
        if(Is_Diamond(r-1)) return r-1;
        return Find_Diamond(l,r-1);
    }
}
int find_best(int n)
{
    quest(0);
    if(Is_Diamond(0)) return 0;
    quest(n-1);
    if(Is_Diamond(n-1)) return n-1;
    return Find_Diamond(0,n-1);
}
/*
int main()
{
    freopen("prize.inp","r",stdin);
    freopen("prize.out","w",stdout);
    int n;
    cin>>n;
    IR.Init(n);
    cout<<find_best(n);
}
*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2492 KB Output is correct
2 Correct 1 ms 2488 KB Output is correct
3 Correct 1 ms 2492 KB Output is correct
4 Correct 1 ms 2492 KB Output is correct
5 Correct 1 ms 2488 KB Output is correct
6 Correct 1 ms 2492 KB Output is correct
7 Correct 1 ms 2908 KB Output is correct
8 Correct 1 ms 2488 KB Output is correct
9 Correct 1 ms 2648 KB Output is correct
10 Correct 1 ms 2488 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2492 KB Output is correct
2 Correct 1 ms 2488 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2492 KB Output is correct
6 Correct 1 ms 2744 KB Output is correct
7 Correct 1 ms 2488 KB Output is correct
8 Correct 1 ms 2484 KB Output is correct
9 Correct 1 ms 2648 KB Output is correct
10 Correct 1 ms 2488 KB Output is correct
11 Correct 1 ms 2520 KB Output is correct
12 Correct 1 ms 2492 KB Output is correct
13 Correct 2 ms 2524 KB Output is correct
14 Correct 1 ms 2748 KB Output is correct
15 Correct 3 ms 3072 KB Output is correct
16 Correct 23 ms 2712 KB Output is correct
17 Correct 1 ms 2492 KB Output is correct
18 Correct 17 ms 3324 KB Output is correct
19 Correct 1 ms 2496 KB Output is correct
20 Correct 4 ms 2864 KB Output is correct
21 Correct 6 ms 3576 KB Output is correct
22 Correct 2 ms 2956 KB Output is correct
23 Correct 1 ms 2492 KB Output is correct
24 Correct 1 ms 2740 KB Output is correct
25 Correct 10 ms 2580 KB Output is correct
26 Correct 12 ms 2772 KB Output is correct
27 Correct 1 ms 2524 KB Output is correct
28 Correct 18 ms 2816 KB Output is correct
29 Correct 19 ms 2540 KB Output is correct
30 Correct 19 ms 2840 KB Output is correct
31 Correct 1 ms 2656 KB Output is correct
32 Correct 2 ms 2524 KB Output is correct
33 Correct 1 ms 2484 KB Output is correct
34 Correct 5 ms 2920 KB Output is correct
35 Correct 1 ms 2656 KB Output is correct
36 Correct 4 ms 3316 KB Output is correct
37 Correct 1 ms 3036 KB Output is correct
38 Correct 1 ms 2492 KB Output is correct
39 Correct 8 ms 2780 KB Output is correct
40 Correct 15 ms 2864 KB Output is correct
41 Correct 12 ms 2836 KB Output is correct
42 Correct 10 ms 3588 KB Output is correct
43 Correct 9 ms 2768 KB Output is correct
44 Correct 9 ms 2996 KB Output is correct
45 Correct 6 ms 3076 KB Output is correct
46 Correct 1 ms 2736 KB Output is correct
47 Correct 9 ms 3056 KB Output is correct
48 Correct 13 ms 2844 KB Output is correct
49 Correct 2 ms 2796 KB Output is correct
50 Correct 27 ms 3068 KB Output is correct
51 Correct 7 ms 3160 KB Output is correct
52 Correct 1 ms 2516 KB Output is correct
53 Correct 1 ms 2492 KB Output is correct
54 Correct 8 ms 3332 KB Output is correct
55 Correct 1 ms 2484 KB Output is correct
56 Correct 22 ms 3068 KB Output is correct
57 Correct 15 ms 2592 KB Output is correct
58 Correct 17 ms 3548 KB Output is correct
59 Correct 11 ms 3080 KB Output is correct
60 Correct 10 ms 3076 KB Output is correct
61 Correct 1 ms 2496 KB Output is correct
62 Correct 1 ms 2488 KB Output is correct
63 Correct 1 ms 2488 KB Output is correct
64 Correct 1 ms 2492 KB Output is correct
65 Correct 1 ms 2492 KB Output is correct
66 Correct 1 ms 2488 KB Output is correct
67 Correct 2 ms 2492 KB Output is correct
68 Correct 2 ms 2492 KB Output is correct
69 Correct 1 ms 2492 KB Output is correct
70 Correct 2 ms 2496 KB Output is correct
71 Correct 20 ms 2668 KB Output is correct
72 Correct 2 ms 2496 KB Output is correct
73 Correct 26 ms 2552 KB Output is correct
74 Correct 17 ms 2900 KB Output is correct
75 Correct 1 ms 2496 KB Output is correct
76 Correct 20 ms 2904 KB Output is correct
77 Correct 20 ms 3000 KB Output is correct
78 Correct 3 ms 2496 KB Output is correct
79 Correct 11 ms 2744 KB Output is correct
80 Correct 21 ms 2752 KB Output is correct
81 Correct 19 ms 3004 KB Output is correct
82 Correct 22 ms 2800 KB Output is correct
83 Correct 2 ms 2496 KB Output is correct
84 Correct 15 ms 3000 KB Output is correct
85 Correct 19 ms 3256 KB Output is correct
86 Correct 1 ms 2492 KB Output is correct
87 Correct 1 ms 2496 KB Output is correct
88 Correct 1 ms 2496 KB Output is correct
89 Correct 2 ms 2488 KB Output is correct
90 Correct 1 ms 2748 KB Output is correct
91 Correct 1 ms 2492 KB Output is correct
92 Correct 1 ms 2496 KB Output is correct
93 Correct 3 ms 3004 KB Output is correct
94 Correct 2 ms 2496 KB Output is correct
95 Correct 2 ms 2744 KB Output is correct
96 Correct 2 ms 2496 KB Output is correct
97 Correct 1 ms 2492 KB Output is correct