QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#371534 | #6394. Turn on the Light | zhoudashuai | WA | 1ms | 3924kb | C++14 | 805b | 2024-03-30 13:48:12 | 2024-03-30 13:48:13 |
Judging History
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!