QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#371515#6394. Turn on the LightzhoudashuaiWA 0ms3888kbC++14831b2024-03-30 13:35:102024-03-30 13:35:11

Judging History

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

  • [2024-03-30 13:35:11]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3888kb
  • [2024-03-30 13:35:10]
  • 提交

answer

#include<iostream>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<queue>
#include<set> 
#include<stack>
#include<bitset>
#include<unordered_map>
#include<iomanip>
#define endl '\n'
#define pb push_back
#define debug(x) cout<<x<<endl; 
#define me(a,x) memset(a,x,sizeof(a))
#define L(i,j,k) for(int i=(j);i<=(k);++i)
#define R(i,j,k) for(int i=(j);i>=(k);--i)
#define int long long 
using namespace std;
typedef long long ll;
typedef pair<int ,int > PII;
typedef unsigned long long ull;
int a[55];
signed main(){
	
	int n;cin>>n;
	int l=1,r=n;
	L(i,1,n){
		int mid=l+r>>1;
		printf("? %d\n",mid);
		cout.flush();
		scanf("%d",&a[i]);
		if(a[i]>a[i-1])l=mid+1;
		else r=mid-1;
		if(a[i]==a[i-1]){
			printf("! %d",mid);
			return 0;
		}
	}
	
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
1
1

output:

? 2
? 3
! 3

result:

ok Correct position at 3

Test #2:

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

input:

10
1
2
3
4
4

output:

? 5
? 8
? 9
? 10
? 10
! 10

result:

wrong answer Wrong answer, more than 1 possible light!