QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#417531#6394. Turn on the LightLCJWA 1ms3736kbC++14650b2024-05-22 19:34:292024-05-22 19:34:30

Judging History

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

  • [2024-05-22 19:34:30]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3736kb
  • [2024-05-22 19:34:29]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e5+10;
int n,m,k,q,ans;
int ask(int x){
	cout<<"? "<<x<<endl;
	cout.flush();
	int res;
	cin>>res;
	return res;
}
void solve(){
	cin>>n;
	k=0;
	int l=11,r=n;
	for(int i=1;i<=10;i++){
		int kk=ask(i);
		if(k==kk){
			cout<<"! "<<i<<endl;
			return;
		}
		k=kk;
	}
	ans=10;
	while(l<=r){
		int mid=(l+r+1)/2;
		ans=ask(mid);
		if(ans==k){
			cout<<"! "<<mid<<endl;
			return;
		}
		if(k<ans){
			k=ans;
			l=mid+1;
		}
		else{
			k=ans;
			r=mid-1;
		}
	}
	
}
signed main(){
	int T=1;
	//cin>>T;
	while(T--){
		solve();
	}
}

詳細信息

Test #1:

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

input:

3
1
2
2

output:

? 1
? 2
? 3
! 3

result:

ok Correct position at 3

Test #2:

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

input:

10
1
2
3
4
5
6
7
8
8

output:

? 1
? 2
? 3
? 4
? 5
? 6
? 7
? 8
? 9
! 9

result:

ok Correct position at 9

Test #3:

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

input:

9
1
2
3
4
5
6
7
7

output:

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

result:

ok Correct position at 8

Test #4:

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

input:

8
1
2
3
4
5
6
6

output:

? 1
? 2
? 3
? 4
? 5
? 6
? 7
! 7

result:

ok Correct position at 7

Test #5:

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

input:

7
1
2
3
4
5
5

output:

? 1
? 2
? 3
? 4
? 5
? 6
! 6

result:

ok Correct position at 6

Test #6:

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

input:

6
1
2
3
4
5
5

output:

? 1
? 2
? 3
? 4
? 5
? 6
! 6

result:

ok Correct position at 6

Test #7:

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

input:

5
1
2
3
3

output:

? 1
? 2
? 3
? 4
! 4

result:

ok Correct position at 4

Test #8:

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

input:

4
1
2
3
3

output:

? 1
? 2
? 3
? 4
! 4

result:

ok Correct position at 4

Test #9:

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

input:

3
1
1

output:

? 1
? 2
! 2

result:

ok Correct position at 2

Test #10:

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

input:

2
1
1

output:

? 1
? 2
! 2

result:

ok Correct position at 2

Test #11:

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

input:

1
0

output:

? 1
! 1

result:

ok Correct position at 1

Test #12:

score: -100
Wrong Answer
time: 1ms
memory: 3660kb

input:

1000000
1
2
3
4
5
6
7
8
9
10
9
8
9
8
7
8
7
6
5
4
3
2
1
0
1
2
3
4
5

output:

? 1
? 2
? 3
? 4
? 5
? 6
? 7
? 8
? 9
? 10
? 500006
? 250008
? 125009
? 187509
? 156259
? 140634
? 148447
? 144541
? 142588
? 141611
? 141123
? 140879
? 140757
? 140696
? 140665
? 140681
? 140689
? 140693
? 140695

result:

wrong answer format  Unexpected end of file - token expected