QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#581481#6394. Turn on the Lightwsxcb#WA 0ms3612kbC++17669b2024-09-22 13:01:202024-09-22 13:01:20

Judging History

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

  • [2024-09-22 13:01:20]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3612kb
  • [2024-09-22 13:01:20]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

void pri(int x) {
	cout << "? " << x << endl;
}

void pri_(int x) {
	cout << "! " << x << endl;
}

void solve() {

	int n;
	cin >> n;

	pri(1);
	int x;
	cin >> x;
	int pre = x;

	if (x == 0) {
		pri_(1);
	} else {
		int le = 2, ri = n;
		while (le <= ri) {
			int mid = (le + ri) >> 1;
			pri(mid);
			cin >> x;
			if (x > pre) {
				le = mid + 1;
			} else if (x < pre) {
				ri = mid - 1;
			} else {
				pri_(mid);
				return;
			}
			pre = x;
		}
	}

}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	int T = 1;
	while (T--) {
		solve();
	}

	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3612kb

input:

3
1
2
2

output:

? 1
? 2
? 3
! 3

result:

ok Correct position at 3

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3600kb

input:

10
1
0
1
2
3

output:

? 1
? 6
? 3
? 4
? 5

result:

wrong answer format  Unexpected end of file - token expected