답안 #975277

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
975277 2024-05-04T16:36:37 Z StefanSebez 커다란 상품 (IOI17_prize) C++14
20 / 100
3 ms 2136 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 nekict=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);nekict++;}
		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()){
		if(nekict>=10000-10) break;
		auto it2=it;
		int i=*it;
		if(res!=-1 && res==i) break;
		it++;
		if(it==st.end()) break;
		int j=*it;
		if(i!=-1 && j!=n && temp[j].fi-temp[i].fi==0) continue;
		int l=i+1,r=j-1;
		//printf("%i %i %i\n",i,j,sajz);
		while(l<=r){
			if(nekict>=10000-10) break;
			int mid=(l+r)/2;
			vector<int>tmp;
			if(temp[mid].fi==-1) {tmp=ask(mid);nekict++;}
			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 1880 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 2136 KB Output is correct
7 Correct 2 ms 1880 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 2 ms 1880 KB Output is correct
3 Correct 2 ms 2136 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 1880 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
11 Correct 3 ms 2136 KB Output is correct
12 Correct 2 ms 1876 KB Output is correct
13 Incorrect 2 ms 1880 KB Integer -1 violates the range [0, 199999]
14 Halted 0 ms 0 KB -