QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#371534#6394. Turn on the LightzhoudashuaiWA 1ms3924kbC++14805b2024-03-30 13:48:122024-03-30 13:48:13

Judging History

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

  • [2024-03-30 13:48:13]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3924kb
  • [2024-03-30 13:48:12]
  • 提交

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)

using namespace std;
typedef long long ll;
typedef pair<int ,int > PII;
typedef unsigned long long ull;
int a[55];
int 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("%lld",&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;
		}
	}
	
}

详细

Test #1:

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

input:

3
1
1

output:

? 2
? 3
! 3

result:

ok Correct position at 3

Test #2:

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

input:

10
1
2
3
4
4

output:

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

result:

wrong answer Wrong answer, more than 1 possible light!