답안 #304807

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
304807 2020-09-21T22:39:59 Z sofapuden Colors (BOI20_colors) C++14
0 / 100
0 ms 256 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

ll fS(ll x){
	ll lo = 1, hi = x, cn = 0, ans = 0, out = 0;
	while(lo <= hi){
		if(cn&1)ans-=(lo+hi)/2;
		else ans +=(lo+hi)/2;
		lo = (lo+hi)/2+1;
		out = min(out, ans);
		cn++;
	}
	return out;
}
		
		

int main(){
	ll n; cin >> n;
	ll start = -fS(n)+1;
	cout << "? " << start << endl;
	ll tr; cin >> tr;
	ll lo = 1, hi = n, best = n, cn = 0, ans = start, x;
	while(lo <= hi && lo != n){
		int mid = (lo+hi)/2;
		if(cn&1)ans-=mid;
		else ans+=mid;
		cout << "? " << ans << endl;
		cin >> x;
		if(x){
			best = mid;
			hi = mid-1;
		}
		else{
			lo = mid+1;
		}
		cn++;
	}
	cout << "= " << best << endl;
}

	
	
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 256 KB Integer parameter [name=k] equals to 8, violates the range [1, 7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 256 KB Integer parameter [name=k] equals to 8, violates the range [1, 7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 256 KB Integer parameter [name=k] equals to 8, violates the range [1, 7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 256 KB Integer parameter [name=k] equals to 8, violates the range [1, 7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 256 KB Integer parameter [name=k] equals to 8, violates the range [1, 7]
2 Halted 0 ms 0 KB -