Submission #528531

# Submission time Handle Problem Language Result Execution time Memory
528531 2022-02-20T13:15:45 Z new_acc The Big Prize (IOI17_prize) C++14
90 / 100
83 ms 1984 KB
    #include<bits/stdc++.h>
    #include "prize.h"
    #define fi first
    #define se second
    using namespace std;
    typedef unsigned long long ll;
    typedef vector<int> vi;
    typedef vector<ll> vl;
    const int N=2e5+10;
    int t[N];
    int t2[N][2];
    set<int>s;
    int n,ile;
    vi que(int a){
    	if(t2[a][0]){
    		vi akt;
    		akt.push_back(t2[a][0]),akt.push_back(t2[a][1]);
    		return akt;
    	}
    	vi akt=ask(a);
    	t2[a][0]=akt[0],t2[a][1]=akt[1];
    	return akt;
    }
    int bs(int pocz,int kon,int x,int l){
    	int sr;
    	while(pocz<=kon){
    		sr=(pocz+kon)/2;
    		vi a=que(sr);
    		ile++;
    		if(a[0]+a[1]==0) return -(sr+1);
    		if(a[0]+a[1]!=x) return sr;
    		if(a[0]>l) kon=sr-1;
    		else pocz=sr+1;
    	}	
    	return INT_MAX;
    }
    int find_best(int m){
    	n=m;	
    	int l=0;
    	int ind=0,p=500;
    	int maxi=0;
    	if(p*p!=n) p++;
    	for(int i=0;i<=min(n,p);i++){
    		vi a=que(i);
    		maxi=max(maxi,a[0]+a[1]);
    		t[i]=a[0]+a[1];
    		if(t[i]==0) return i;
    	}
    	while(ind<n-1){
    		s.insert(ind);
    		if(t[ind]==maxi) {p=t[ind];break;}
    		ind++,l++;
    	}	
    	auto it=s.end();
    	it--;
    	s.insert(n);
    	while(*it!=n){
    		auto it2=it;
    		it2++;
    		ile=0;
    		int k=*it2-1;
    		vi akt=que(k);
    		while(k>=*it+1 and akt[0]+akt[1]!=maxi){
    			if(akt[0]+akt[1]==0) return k;
    			s.insert(k),k--,akt=que(k);
    		}
    		if(k>=*it+1){
    			vi akt=que(k);
    			if(akt[0]+akt[1]==0) return k;
    			if(akt[0]==l){
    				l++,it++;
    				continue;
    			}
    		}else {l++,it++;continue;}
    		int pom=bs(*it+1,k,p,l);
    		if(pom!=INT_MAX){
    			if(pom<0) return abs(pom)-1;
    			s.insert(pom);
    		}
    	}
    	return 0;
    }
# Verdict Execution time Memory Grader output
1 Correct 5 ms 328 KB Output is correct
2 Correct 2 ms 312 KB Output is correct
3 Correct 5 ms 288 KB Output is correct
4 Correct 6 ms 280 KB Output is correct
5 Correct 5 ms 200 KB Output is correct
6 Correct 0 ms 288 KB Output is correct
7 Correct 4 ms 296 KB Output is correct
8 Correct 4 ms 288 KB Output is correct
9 Correct 5 ms 272 KB Output is correct
10 Correct 5 ms 312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 200 KB Output is correct
2 Correct 5 ms 292 KB Output is correct
3 Correct 5 ms 296 KB Output is correct
4 Correct 4 ms 200 KB Output is correct
5 Correct 4 ms 280 KB Output is correct
6 Correct 1 ms 200 KB Output is correct
7 Correct 3 ms 344 KB Output is correct
8 Correct 2 ms 308 KB Output is correct
9 Correct 4 ms 328 KB Output is correct
10 Correct 5 ms 328 KB Output is correct
11 Correct 5 ms 584 KB Output is correct
12 Correct 5 ms 280 KB Output is correct
13 Correct 6 ms 932 KB Output is correct
14 Correct 3 ms 308 KB Output is correct
15 Correct 12 ms 928 KB Output is correct
16 Partially correct 43 ms 1692 KB Partially correct - number of queries: 6767
17 Correct 4 ms 292 KB Output is correct
18 Partially correct 62 ms 1820 KB Partially correct - number of queries: 7856
19 Correct 5 ms 296 KB Output is correct
20 Correct 22 ms 796 KB Output is correct
21 Correct 22 ms 920 KB Output is correct
22 Correct 10 ms 804 KB Output is correct
23 Correct 5 ms 328 KB Output is correct
24 Correct 6 ms 304 KB Output is correct
25 Correct 17 ms 1396 KB Output is correct
26 Correct 47 ms 1436 KB Output is correct
27 Correct 3 ms 340 KB Output is correct
28 Partially correct 51 ms 1800 KB Partially correct - number of queries: 6557
29 Partially correct 20 ms 1696 KB Partially correct - number of queries: 5063
30 Partially correct 75 ms 1820 KB Partially correct - number of queries: 7755
31 Correct 5 ms 200 KB Output is correct
32 Correct 10 ms 832 KB Output is correct
33 Correct 1 ms 200 KB Output is correct
34 Correct 22 ms 1180 KB Output is correct
35 Correct 4 ms 596 KB Output is correct
36 Correct 20 ms 1188 KB Output is correct
37 Correct 5 ms 448 KB Output is correct
38 Correct 4 ms 272 KB Output is correct
39 Correct 32 ms 1472 KB Output is correct
40 Partially correct 44 ms 1844 KB Partially correct - number of queries: 6770
41 Correct 52 ms 1432 KB Output is correct
42 Correct 37 ms 1440 KB Output is correct
43 Correct 48 ms 1532 KB Output is correct
44 Correct 28 ms 1220 KB Output is correct
45 Correct 19 ms 1096 KB Output is correct
46 Correct 4 ms 268 KB Output is correct
47 Correct 36 ms 1184 KB Output is correct
48 Partially correct 52 ms 1540 KB Partially correct - number of queries: 5967
49 Correct 11 ms 668 KB Output is correct
50 Partially correct 78 ms 1764 KB Partially correct - number of queries: 7848
51 Correct 30 ms 1344 KB Output is correct
52 Correct 5 ms 328 KB Output is correct
53 Correct 7 ms 408 KB Output is correct
54 Correct 19 ms 1368 KB Output is correct
55 Correct 2 ms 296 KB Output is correct
56 Partially correct 70 ms 1944 KB Partially correct - number of queries: 7835
57 Partially correct 55 ms 1576 KB Partially correct - number of queries: 5798
58 Correct 50 ms 1436 KB Output is correct
59 Correct 44 ms 1436 KB Output is correct
60 Correct 32 ms 1344 KB Output is correct
61 Correct 6 ms 416 KB Output is correct
62 Correct 7 ms 292 KB Output is correct
63 Correct 6 ms 320 KB Output is correct
64 Correct 4 ms 288 KB Output is correct
65 Correct 4 ms 200 KB Output is correct
66 Correct 5 ms 300 KB Output is correct
67 Correct 11 ms 276 KB Output is correct
68 Correct 6 ms 292 KB Output is correct
69 Correct 7 ms 288 KB Output is correct
70 Correct 8 ms 328 KB Output is correct
71 Partially correct 67 ms 1864 KB Partially correct - number of queries: 8280
72 Correct 11 ms 1088 KB Output is correct
73 Partially correct 83 ms 1808 KB Partially correct - number of queries: 8155
74 Partially correct 62 ms 1812 KB Partially correct - number of queries: 8225
75 Correct 7 ms 440 KB Output is correct
76 Partially correct 71 ms 1832 KB Partially correct - number of queries: 7137
77 Partially correct 59 ms 1852 KB Partially correct - number of queries: 7522
78 Correct 9 ms 1100 KB Output is correct
79 Correct 47 ms 1848 KB Output is correct
80 Partially correct 69 ms 1856 KB Partially correct - number of queries: 7369
81 Partially correct 38 ms 1984 KB Partially correct - number of queries: 7607
82 Partially correct 55 ms 1820 KB Partially correct - number of queries: 7181
83 Correct 7 ms 440 KB Output is correct
84 Partially correct 54 ms 1824 KB Partially correct - number of queries: 6071
85 Partially correct 79 ms 1764 KB Partially correct - number of queries: 7207
86 Correct 4 ms 312 KB Output is correct
87 Correct 5 ms 296 KB Output is correct
88 Correct 6 ms 312 KB Output is correct
89 Correct 7 ms 304 KB Output is correct
90 Correct 5 ms 328 KB Output is correct
91 Correct 5 ms 308 KB Output is correct
92 Correct 2 ms 308 KB Output is correct
93 Correct 10 ms 864 KB Output is correct
94 Correct 9 ms 936 KB Output is correct
95 Correct 10 ms 944 KB Output is correct
96 Correct 8 ms 712 KB Output is correct
97 Correct 5 ms 316 KB Output is correct