답안 #975164

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
975164 2024-05-04T14:11:39 Z StefanSebez 커다란 상품 (IOI17_prize) C++14
20 / 100
57 ms 3340 KB
#include "prize.h"
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
mt19937 rng(time(0));
int find_best(int n){
	pair<int,int> temp[n+10];
	for(int i=0;i<n;i++) temp[i].fi=temp[i].se=-1;
	int ct=150,V=n;
	while(ct--){
		int x=rng()%n;
		vector<int>tmp;
		if(temp[x].fi==-1) tmp=ask(x);
		else tmp.pb(temp[x].fi),tmp.pb(temp[x].se);
		temp[x]={tmp[0],tmp[1]};
		if(n-(tmp[0]+tmp[1])<V) V=n-(tmp[0]+tmp[1]);
	}
	int res=-1;
	set<int>st;
	st.insert(-1),st.insert(n);
	auto it=st.begin();
	int sajz=0;
	while(it!=st.end()){
		auto it2=it;
		int i=*it;
		if(res!=-1 && res==i) break;
		it++;
		if(it==st.end()) break;
		int j=*it;
		int l=i+1,r=j-1;
		//printf("%i %i %i\n",i,j,sajz);
		while(l<=r){
			int mid=(l+r)/2;
			vector<int>tmp;
			if(temp[mid].fi==-1) tmp=ask(mid);
			else tmp.pb(temp[mid].fi),tmp.pb(temp[mid].se);
			temp[mid]={tmp[0],tmp[1]};
			if(n-tmp[0]-tmp[1]!=V){
				if(tmp[0]==0 && tmp[1]==0) {res=mid;break;}
				st.insert(mid);
				r=mid-1;
				continue;
			}
			if(tmp[0]>=1+sajz) r=mid-1;
			else l=mid+1;
		}
		it=it2;
		it++;
		sajz++;
	}
	for(auto i=st.begin();i!=st.end();i++){
		int x=*i;
		if(x==-1 || x==n) continue;
		if(temp[x].fi==0 && temp[x].se==0) res=x;
	}
	//for(auto i=st.begin();i!=st.end();i++) printf("%i ",*i);
	//printf("\n");
	/*for(int i = 0; i < n; i++) {
		std::vector<int> res = ask(i);
		if(res[0] + res[1] == 0)
			return i;
	}*/
	return res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1880 KB Output is correct
2 Correct 2 ms 1880 KB Output is correct
3 Correct 2 ms 1800 KB Output is correct
4 Correct 2 ms 1880 KB Output is correct
5 Correct 2 ms 1880 KB Output is correct
6 Correct 2 ms 1880 KB Output is correct
7 Correct 2 ms 2132 KB Output is correct
8 Correct 2 ms 1880 KB Output is correct
9 Correct 2 ms 1880 KB Output is correct
10 Correct 2 ms 1880 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1880 KB Output is correct
2 Correct 3 ms 1880 KB Output is correct
3 Correct 2 ms 1880 KB Output is correct
4 Correct 2 ms 1880 KB Output is correct
5 Correct 2 ms 2136 KB Output is correct
6 Correct 2 ms 1880 KB Output is correct
7 Correct 2 ms 1880 KB Output is correct
8 Correct 2 ms 2132 KB Output is correct
9 Correct 2 ms 1880 KB Output is correct
10 Correct 2 ms 1880 KB Output is correct
11 Correct 3 ms 1880 KB Output is correct
12 Correct 2 ms 1880 KB Output is correct
13 Correct 4 ms 1880 KB Output is correct
14 Correct 2 ms 344 KB Output is correct
15 Correct 6 ms 2004 KB Output is correct
16 Partially correct 32 ms 2008 KB Partially correct - number of queries: 6642
17 Correct 2 ms 1880 KB Output is correct
18 Partially correct 40 ms 2252 KB Partially correct - number of queries: 7755
19 Correct 2 ms 1880 KB Output is correct
20 Correct 11 ms 1220 KB Output is correct
21 Correct 14 ms 2008 KB Output is correct
22 Correct 4 ms 1880 KB Output is correct
23 Correct 2 ms 1880 KB Output is correct
24 Correct 3 ms 1880 KB Output is correct
25 Correct 19 ms 2000 KB Output is correct
26 Correct 23 ms 1996 KB Output is correct
27 Correct 2 ms 1880 KB Output is correct
28 Partially correct 34 ms 2004 KB Partially correct - number of queries: 6507
29 Correct 22 ms 2264 KB Output is correct
30 Partially correct 41 ms 2500 KB Partially correct - number of queries: 7690
31 Correct 2 ms 1880 KB Output is correct
32 Correct 4 ms 1972 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 14 ms 2136 KB Output is correct
35 Correct 3 ms 1880 KB Output is correct
36 Correct 10 ms 2000 KB Output is correct
37 Correct 3 ms 1880 KB Output is correct
38 Correct 2 ms 1880 KB Output is correct
39 Correct 24 ms 2004 KB Output is correct
40 Partially correct 29 ms 2004 KB Partially correct - number of queries: 6602
41 Correct 24 ms 2004 KB Output is correct
42 Correct 19 ms 2012 KB Output is correct
43 Correct 37 ms 2000 KB Output is correct
44 Correct 14 ms 2004 KB Output is correct
45 Correct 12 ms 2012 KB Output is correct
46 Correct 2 ms 1880 KB Output is correct
47 Correct 15 ms 2000 KB Output is correct
48 Partially correct 35 ms 2244 KB Partially correct - number of queries: 5793
49 Correct 4 ms 1880 KB Output is correct
50 Partially correct 38 ms 2760 KB Partially correct - number of queries: 7742
51 Correct 14 ms 2012 KB Output is correct
52 Correct 2 ms 1880 KB Output is correct
53 Correct 3 ms 2128 KB Output is correct
54 Correct 16 ms 2004 KB Output is correct
55 Correct 2 ms 1880 KB Output is correct
56 Partially correct 41 ms 2268 KB Partially correct - number of queries: 7757
57 Partially correct 28 ms 2240 KB Partially correct - number of queries: 5663
58 Correct 27 ms 2240 KB Output is correct
59 Correct 22 ms 2240 KB Output is correct
60 Correct 17 ms 2260 KB Output is correct
61 Correct 2 ms 1880 KB Output is correct
62 Correct 2 ms 1880 KB Output is correct
63 Correct 2 ms 1880 KB Output is correct
64 Correct 2 ms 1880 KB Output is correct
65 Correct 2 ms 1880 KB Output is correct
66 Correct 4 ms 2020 KB Output is correct
67 Correct 4 ms 2260 KB Output is correct
68 Correct 5 ms 2008 KB Output is correct
69 Correct 5 ms 2516 KB Output is correct
70 Correct 3 ms 2008 KB Output is correct
71 Partially correct 45 ms 2252 KB Partially correct - number of queries: 7983
72 Correct 5 ms 1880 KB Output is correct
73 Partially correct 44 ms 2244 KB Partially correct - number of queries: 7857
74 Partially correct 39 ms 2256 KB Partially correct - number of queries: 7927
75 Correct 3 ms 1880 KB Output is correct
76 Partially correct 47 ms 2004 KB Partially correct - number of queries: 6805
77 Partially correct 51 ms 2500 KB Partially correct - number of queries: 7322
78 Correct 4 ms 1880 KB Output is correct
79 Correct 17 ms 2256 KB Output is correct
80 Partially correct 52 ms 2496 KB Partially correct - number of queries: 6941
81 Partially correct 31 ms 2000 KB Partially correct - number of queries: 6556
82 Partially correct 38 ms 2500 KB Partially correct - number of queries: 7408
83 Correct 2 ms 1880 KB Output is correct
84 Partially correct 26 ms 2000 KB Partially correct - number of queries: 6089
85 Partially correct 38 ms 2244 KB Partially correct - number of queries: 7415
86 Correct 22 ms 2236 KB Output is correct
87 Correct 2 ms 1880 KB Output is correct
88 Correct 23 ms 2252 KB Output is correct
89 Correct 19 ms 2516 KB Output is correct
90 Correct 2 ms 1880 KB Output is correct
91 Correct 10 ms 2000 KB Output is correct
92 Correct 22 ms 2260 KB Output is correct
93 Incorrect 57 ms 3340 KB Incorrect
94 Halted 0 ms 0 KB -