QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#571907#6394. Turn on the Lightzfasion#WA 1ms3684kbC++141.3kb2024-09-18 10:12:222024-09-18 10:12:23

Judging History

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

  • [2024-09-18 10:12:23]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3684kb
  • [2024-09-18 10:12:22]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const long long N = 3e6 + 20, M = 998244353;
#define eps 1e-12
#define int long long
// #define int __int128
#define ll long long
#define all(x) x.begin(), x.end()
// #define endl '\n'
#define ls (p << 1)
#define rs ((p << 1) | 1)
#define f1 first
#define pb push_back
#define f2 second
#define IOS std::ios::sync_with_stdio(0), std::cin.tie(0), std::cout.tie(0), std::cout << std::fixed << std::setprecision(2);

int read()
{
	int x = 0, f = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9')
	{
		f = -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9')
	{
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	x *= f;
	return x;
}
void write(int x)
{
	if (x < 0)
	{
		putchar('-');
		x = -x;
	}
	if (x > 9)
		write(x / 10);
	putchar(x % 10 + '0');
}
signed main()
{
	IOS;
	int n;
	cin >> n;
	int l = 1, r = n;
	auto ask = [&](int x) -> int
	{
		cout << "? " << x << endl;
		int d;
		cin >> d;
		return d;
	};
	int pre = 0, ans = l + r >> 1;
	while (l < r)
	{
		int mid = l + r >> 1;
		int d = ask(mid);
		if (d == pre)
		{
			ans = mid;
			break;
		}
		pre = d;
		d = ask(l);
		if (d == pre + 1)
		{
			l = mid + 1;
		}
		else
		{
			r = mid - 1, l++;
		}
		pre=d;
		ans=l;
	}
	cout << "! " << ans << endl;
	return false;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
1
2

output:

? 2
? 1
! 3

result:

ok Correct position at 3

Test #2:

score: 0
Accepted
time: 1ms
memory: 3556kb

input:

10
1
2
3
4
5
5

output:

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

result:

ok Correct position at 10

Test #3:

score: 0
Accepted
time: 1ms
memory: 3636kb

input:

9
1
2
3
4
5
5

output:

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

result:

ok Correct position at 9

Test #4:

score: 0
Accepted
time: 0ms
memory: 3580kb

input:

8
1
2
3
4
5
5

output:

? 4
? 1
? 6
? 5
? 7
? 7
! 8

result:

ok Correct position at 8

Test #5:

score: 0
Accepted
time: 1ms
memory: 3624kb

input:

7
1
2
3
4

output:

? 4
? 1
? 6
? 5
! 7

result:

ok Correct position at 7

Test #6:

score: 0
Accepted
time: 1ms
memory: 3616kb

input:

6
1
2
3
4

output:

? 3
? 1
? 5
? 4
! 6

result:

ok Correct position at 6

Test #7:

score: 0
Accepted
time: 1ms
memory: 3624kb

input:

5
1
2
3
3

output:

? 3
? 1
? 4
? 4
! 5

result:

ok Correct position at 5

Test #8:

score: 0
Accepted
time: 0ms
memory: 3628kb

input:

4
1
2
3
3

output:

? 2
? 1
? 3
? 3
! 4

result:

ok Correct position at 4

Test #9:

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

input:

3
1
1

output:

? 2
? 1
! 2

result:

wrong answer Wrong favorite light!