QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#136499#6394. Turn on the Lightammardab3an#WA 2ms3592kbC++17819b2023-08-08 21:44:122023-08-08 21:44:13

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-08 21:44:13]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3592kb
  • [2023-08-08 21:44:12]
  • 提交

answer

#include <bits/stdc++.h>

#define ll long long


using namespace std;

const ll N = 1e6 + 10, MM = 1e9 + 7, MAX = 1e18;

int ask(int x) {
	cout << "? " << x << endl;
	int y; cin >> y;
	return y;
}

int solve() {
	int n; cin >> n;
	int l = 1, r = n;
	int res = 0;
	int cur = 0;
	while (l <= r) {
		int mid = l + r >> 1;
		int y = ask(l);
		if (y == cur) {
			res = l;
			break;
		}
		int y1 = ask(mid);
		if (y1 == y) {
			res = mid;
			break;
		}
		if (y1 == cur) {
			r = mid - 1;
			l++;
		}
		else {
			l = mid + 1;
		}
	}
	cout << "! " << res << endl;
	return 0;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	//cin >> t;
	int i = 1;
	while (t--) {
		//cout << "case " << i << ": ";
		solve();
	}
	return 0;
}
/*

*/

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3592kb

input:

3
1
2
2
2

output:

? 1
? 2
? 3
? 3
! 3

result:

ok Correct position at 3

Test #2:

score: -100
Wrong Answer
time: 2ms
memory: 3488kb

input:

10
1
2
3
4
5
5

output:

? 1
? 5
? 6
? 8
? 9
? 9
! 9

result:

wrong answer Wrong favorite light!