답안 #1049610

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1049610 2024-08-09T02:18:16 Z LittleOrange 커다란 상품 (IOI17_prize) C++17
20 / 100
2 ms 2132 KB
#include "prize.h"
#include<bits/stdc++.h>
using namespace std;
using ll = int;
int find_best(int n) {
	mt19937_64 mt(random_device{}());
	vector<array<ll,2>> mem(n,{-1,-1});
	auto qry = [&](ll i){
		if (mem[i][0]==-1){
			auto a = ask(i);
			mem[i] = {a[0],a[1]};
		}
		return mem[i];
	};
	/*
	ll cnt = 0;
	vector<ll> a(n);
	iota(a.begin(),a.end(),0);
	shuffle(a.begin(),a.end(),mt);*/
	ll ans = -1;
	function<void(ll,ll)> dfs;
	dfs = [&](ll l, ll r){
		if (ans != -1) return;
		if (l == r){
			ans = l;
			return;
		}
		ll m = l+mt()%(r-l+1);
		auto o = qry(m);
		if (o[0]+o[1]==0) {
			ans = m;
			return;
		}
		if (o[0]){
			dfs(l,m-1);
		}
		if(o[1]){
			dfs(m+1,r);
		}
	};
	dfs(0,n-1);
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2132 KB Output is correct
2 Correct 1 ms 1880 KB Output is correct
3 Correct 1 ms 1880 KB Output is correct
4 Correct 1 ms 1880 KB Output is correct
5 Correct 1 ms 1880 KB Output is correct
6 Correct 1 ms 1880 KB Output is correct
7 Correct 1 ms 1880 KB Output is correct
8 Correct 2 ms 1876 KB Output is correct
9 Correct 1 ms 1880 KB Output is correct
10 Correct 1 ms 1880 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1880 KB Output is correct
2 Correct 1 ms 1880 KB Output is correct
3 Correct 1 ms 1880 KB Output is correct
4 Correct 1 ms 2132 KB Output is correct
5 Correct 1 ms 1880 KB Output is correct
6 Correct 1 ms 1880 KB Output is correct
7 Correct 1 ms 1880 KB Output is correct
8 Correct 1 ms 1880 KB Output is correct
9 Correct 1 ms 1880 KB Output is correct
10 Correct 1 ms 1880 KB Output is correct
11 Incorrect 1 ms 1880 KB answer is not correct
12 Halted 0 ms 0 KB -