QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#371515 | #6394. Turn on the Light | zhoudashuai | WA | 0ms | 3888kb | C++14 | 831b | 2024-03-30 13:35:10 | 2024-03-30 13:35:11 |
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)
#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!