답안 #256128

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
256128 2020-08-02T10:10:54 Z 송준혁(#5030) Colors (BOI20_colors) C++17
0 / 100
1 ms 256 KB
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define Mup(a,x) a=max(a, x)
#define mup(a,x) a=min(a, x)
#define all(v) v.begin(),v.end()
#define lb lower_bound
#define INF (1ll<<60)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

LL N, ans;

LL qry(LL x){
	printf("? %lld\n", x);
	fflush(stdout);
	scanf("%lld", &x);
	return x;
}

int main(){
	scanf("%lld", &N);
	LL lo=1, hi=N-1, t=1, x=1;
	for (int i=N>>2; i; i>>=2) x+=i;
	if (N == 3) x=2;
	qry(x);
	while (lo<=hi){
		LL m = (lo+hi)/2;
		if (t) x += m;
		else x -= m;
		if (qry(x)) ans = m, hi=m-1;
		else lo=m+1;
		t ^= 1;
	}
	printf("= %lld\n", ans);
	return 0;
}

Compilation message

Colors.cpp: In function 'LL qry(LL)':
Colors.cpp:19:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld", &x);
  ~~~~~^~~~~~~~~~~~
Colors.cpp: In function 'int main()':
Colors.cpp:24:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld", &N);
  ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 256 KB Integer parameter [name=k] equals to 0, violates the range [1, 7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 256 KB Integer parameter [name=k] equals to 0, violates the range [1, 7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 256 KB Integer parameter [name=k] equals to 0, violates the range [1, 7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 256 KB Integer parameter [name=k] equals to 0, violates the range [1, 7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 256 KB Integer parameter [name=k] equals to 0, violates the range [1, 7]
2 Halted 0 ms 0 KB -