답안 #533096

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
533096 2022-03-04T18:25:49 Z kabika Colors (BOI20_colors) C++17
0 / 100
1 ms 200 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;
constexpr ll INF = 1e18;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin >> n;
	vector<bool> vis(n + 1, 0);
	cout << "? 1\n";
	vis[1] = 1;
	bool resp;
	cin >> resp;
	bool flag = 1;
	ll l = 1, u = n;
	ll diff = (l + u) / 2;
	ll qr = l + diff;
	while (l < u)
	{
		cout << "? " << qr << endl;
		vis[qr] = 1;
		cin >> resp;
		if (resp)
		{
			u = diff;
		}
		else
		{
			l = diff + 1;
		}
		diff = (l + u) / 2;
		if (qr - diff >= 1 && !vis[qr - diff])
		{
			qr -= diff;
			continue;
		}
		if (qr + diff <= n && !vis[qr + diff])
		{
			qr += diff;
			continue;
		}
		break;
	}
	cout << "= " << l << endl;
	return 0;
}

Compilation message

Colors.cpp: In function 'int main()':
Colors.cpp:21:7: warning: unused variable 'flag' [-Wunused-variable]
   21 |  bool flag = 1;
      |       ^~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1 ms 200 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1 ms 200 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1 ms 200 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1 ms 200 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1 ms 200 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -