Submission #68871

# Submission time Handle Problem Language Result Execution time Memory
68871 2018-08-18T20:39:15 Z alenam0161 The Big Prize (IOI17_prize) C++17
100 / 100
85 ms 7748 KB
#include "prize.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 3e5+7;
vector<int> ans[N];
int rs=-1;
int gdl,gdr;
vector<int> get(int x){
    if(ans[x].size()==0){
        ans[x]=ask(x);
        if(ans[x][0]==0&&ans[x][1]==0){
            rs=x;
            return ans[x];
        }
        if(ans[x][0]==0)gdl=max(gdl,x);
        if(ans[x][1]==0)gdr=min(gdr,x);
   // cout<<x<<" "<<ans[x][0]<<" "<<ans[x][1]<<endl;
    }
    return ans[x];
}
void fnd(int l,int r){
    if(rs!=-1)return;
    if(l==r){
        if(gdl<=l&&l<=gdr)
        get(l);
        return;
    }
    if(l+1==r){
        return;
    }
    int m=(l+r)/2;
    if(gdl>=m){
        fnd(m,r);
        return;
    }
    if(gdr<=m){
        fnd(l,m);
        return;
    }
    vector<int> lres=get(l);
    if(rs!=-1)return;
    vector<int> rres=get(r);
    if(rs!=-1)return;
    if(lres[0]==rres[0]&&lres[1]==rres[1])return;
    if(lres[1]==0||rres[0]==0)return;
    vector<int> md=get(m);
    if(rs!=-1)return;
    if(rand()&1){
        if(md[0]!=0)fnd(l,m);
        if(rs!=-1)return;
        if(md[1]!=0)fnd(m,r);
    }
    else{
        if(md[1]!=0)fnd(m,r);
        if(rs!=-1)return;
        if(md[0]!=0)fnd(l,m);
    }
}
int find_best(int n) {
    srand(6451719);
    gdl=-1;
    gdr=n;
    fnd(0,n-1);
    return rs;

    int i;
	for(i = 0; i < n; i++) {
		std::vector<int> res = get(i);
	//	cout<<i<<" ok "<<res[0]<<" "<<res[1]<<endl;
		if(res[0] + res[1] == 0)
			return i;
        int cur=i;
        int brd=20;
        if(res[0]+res[1]<n/2)brd=3;
        else brd=20;

        for(int j=brd;j>=0;j--){
            int rg=cur;
            rg+=1<<j;
            if(rg<n){
                vector<int> cres=get(rg);
              //  cout<<rg<<" "<<cur<<" "<<j<<" ok "<<cres[0]<<" "<<cres[1]<<endl;
                if(cres[0]+cres[1]==0)return rg;
                if(res[0]==cres[0]&&res[1]==cres[1]){
                    cur=rg;
                    continue;
                }
                if(cres[0]==0){
                    cur=rg;
                    continue;
                }
            }
        }
        i=cur;
	}
	return n-1;
}
# Verdict Execution time Memory Grader output
1 Correct 10 ms 7416 KB Output is correct
2 Correct 8 ms 7420 KB Output is correct
3 Correct 9 ms 7428 KB Output is correct
4 Correct 9 ms 7428 KB Output is correct
5 Correct 9 ms 7428 KB Output is correct
6 Correct 8 ms 7608 KB Output is correct
7 Correct 8 ms 7608 KB Output is correct
8 Correct 9 ms 7664 KB Output is correct
9 Correct 8 ms 7664 KB Output is correct
10 Correct 9 ms 7664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 7736 KB Output is correct
2 Correct 9 ms 7736 KB Output is correct
3 Correct 9 ms 7736 KB Output is correct
4 Correct 11 ms 7736 KB Output is correct
5 Correct 9 ms 7736 KB Output is correct
6 Correct 8 ms 7736 KB Output is correct
7 Correct 10 ms 7736 KB Output is correct
8 Correct 8 ms 7736 KB Output is correct
9 Correct 8 ms 7736 KB Output is correct
10 Correct 9 ms 7736 KB Output is correct
11 Correct 14 ms 7736 KB Output is correct
12 Correct 12 ms 7736 KB Output is correct
13 Correct 9 ms 7736 KB Output is correct
14 Correct 16 ms 7736 KB Output is correct
15 Correct 14 ms 7736 KB Output is correct
16 Correct 12 ms 7736 KB Output is correct
17 Correct 37 ms 7744 KB Output is correct
18 Correct 21 ms 7744 KB Output is correct
19 Correct 35 ms 7744 KB Output is correct
20 Correct 19 ms 7744 KB Output is correct
21 Correct 35 ms 7744 KB Output is correct
22 Correct 34 ms 7744 KB Output is correct
23 Correct 11 ms 7744 KB Output is correct
24 Correct 13 ms 7744 KB Output is correct
25 Correct 20 ms 7744 KB Output is correct
26 Correct 17 ms 7744 KB Output is correct
27 Correct 10 ms 7744 KB Output is correct
28 Correct 16 ms 7744 KB Output is correct
29 Correct 10 ms 7744 KB Output is correct
30 Correct 18 ms 7744 KB Output is correct
31 Correct 24 ms 7744 KB Output is correct
32 Correct 11 ms 7744 KB Output is correct
33 Correct 10 ms 7744 KB Output is correct
34 Correct 26 ms 7744 KB Output is correct
35 Correct 11 ms 7744 KB Output is correct
36 Correct 52 ms 7744 KB Output is correct
37 Correct 11 ms 7744 KB Output is correct
38 Correct 11 ms 7744 KB Output is correct
39 Correct 27 ms 7744 KB Output is correct
40 Correct 22 ms 7744 KB Output is correct
41 Correct 18 ms 7744 KB Output is correct
42 Correct 14 ms 7744 KB Output is correct
43 Correct 16 ms 7748 KB Output is correct
44 Correct 34 ms 7748 KB Output is correct
45 Correct 43 ms 7748 KB Output is correct
46 Correct 31 ms 7748 KB Output is correct
47 Correct 52 ms 7748 KB Output is correct
48 Correct 13 ms 7748 KB Output is correct
49 Correct 32 ms 7748 KB Output is correct
50 Correct 18 ms 7748 KB Output is correct
51 Correct 30 ms 7748 KB Output is correct
52 Correct 32 ms 7748 KB Output is correct
53 Correct 8 ms 7748 KB Output is correct
54 Correct 23 ms 7748 KB Output is correct
55 Correct 46 ms 7748 KB Output is correct
56 Correct 15 ms 7748 KB Output is correct
57 Correct 10 ms 7748 KB Output is correct
58 Correct 13 ms 7748 KB Output is correct
59 Correct 18 ms 7748 KB Output is correct
60 Correct 19 ms 7748 KB Output is correct
61 Correct 28 ms 7748 KB Output is correct
62 Correct 9 ms 7748 KB Output is correct
63 Correct 9 ms 7748 KB Output is correct
64 Correct 10 ms 7748 KB Output is correct
65 Correct 10 ms 7748 KB Output is correct
66 Correct 9 ms 7748 KB Output is correct
67 Correct 9 ms 7748 KB Output is correct
68 Correct 8 ms 7748 KB Output is correct
69 Correct 10 ms 7748 KB Output is correct
70 Correct 10 ms 7748 KB Output is correct
71 Correct 61 ms 7748 KB Output is correct
72 Correct 13 ms 7748 KB Output is correct
73 Correct 52 ms 7748 KB Output is correct
74 Correct 51 ms 7748 KB Output is correct
75 Correct 11 ms 7748 KB Output is correct
76 Correct 45 ms 7748 KB Output is correct
77 Correct 63 ms 7748 KB Output is correct
78 Correct 14 ms 7748 KB Output is correct
79 Correct 23 ms 7748 KB Output is correct
80 Correct 57 ms 7748 KB Output is correct
81 Correct 85 ms 7748 KB Output is correct
82 Correct 36 ms 7748 KB Output is correct
83 Correct 10 ms 7748 KB Output is correct
84 Correct 37 ms 7748 KB Output is correct
85 Correct 56 ms 7748 KB Output is correct
86 Correct 21 ms 7748 KB Output is correct
87 Correct 9 ms 7748 KB Output is correct
88 Correct 14 ms 7748 KB Output is correct
89 Correct 10 ms 7748 KB Output is correct
90 Correct 10 ms 7748 KB Output is correct
91 Correct 10 ms 7748 KB Output is correct
92 Correct 9 ms 7748 KB Output is correct
93 Correct 12 ms 7748 KB Output is correct
94 Correct 12 ms 7748 KB Output is correct
95 Correct 14 ms 7748 KB Output is correct
96 Correct 10 ms 7748 KB Output is correct
97 Correct 10 ms 7748 KB Output is correct