QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#387246#6394. Turn on the Light1ockhart#WA 0ms3740kbC++201006b2024-04-12 10:57:382024-04-12 10:57:40

Judging History

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

  • [2024-04-12 10:57:40]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3740kb
  • [2024-04-12 10:57:38]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("avx2")

using ll = long long;
//using i128 = __int128_t;
//#define endl "\n"
#define int long long
#define db cout << "db" << endl;
#define x first
#define y second
typedef pair<int, int> PII;
const int N = 5e5 + 10;
ll inf = 2e18;
void solve() {
	int n;
	cin >> n;
	int l = 1, r = n, cnt = 0;
	while (l <= r) {
		int mid = (l + r) >> 1, x1, x2;
		cout << "? " << l << endl; cnt++;
		cin >> x1;
		if (cnt % 2 != x1 % 2) {
			cout << "! " << l << endl;
			return;
		}
		cout << "? " << mid << endl; cnt++;
		cin >> x2;
		if (cnt % 2 != x2 % 2) {
			cout << "! " << l << endl;
			return;
		}
		if (x2 > x1) l = mid + 1;
		else r = mid - 1;
	}	
    
}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int q = 1;
    //cin >> q;
    while (q --) {
        solve();
    }
    return 0;
} 

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 3740kb

input:

10
1
2
3
4
5
5

output:

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

result:

wrong answer Wrong favorite light!