QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#218075 | #6394. Turn on the Light | CRN2010 | WA | 1ms | 3644kb | C++20 | 1.3kb | 2023-10-17 18:06:14 | 2023-10-17 18:06:15 |
Judging History
answer
#include <bits/stdc++.h>
#define int unsigned long long
#define ls (x << 1)
#define rs (x << 1 | 1 )
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define FOR(x,y,z) for(int x = (y) ; x <= z ; ++x )
#define FOR_(x,y,z) for(int x = (y) ; x >= z ; --x )
#define all(x) x.begin(),x.end()
//#define endl '\n'
const int N = 1e5+5;
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
using namespace std;
inline int read() {
int ans=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-'){f=-1;}ch=getchar();}
while(ch>='0'&&ch<='9'){ans=(ans<<3)+(ans<<1)+(ch^48);ch=getchar();}
return ans*f;
}
void write(int x) {
if(x<0){putchar('-');x=-1;}
if(x>9){write(x/10);}
putchar(x%10|48);
}
void solve() {
int n , pre = 0 , now = 0;
n = read() ;
int left = 1 , right = n ;
while( right >= left ) {
if ( pre == 0 ) {
cout << "? " << left << endl;
pre = read() ;
++left;
}
int mid = (left + right) >> 1 ;
cout << "? " << mid << endl ;
now = read() ;
if ( now == pre ) {
cout << "! " << mid << endl ;
return ;
}
else if ( now > pre ) {
left = mid + 1;
}
else {
right = mid + 1;
}
pre = now ;
}
return ;
}
signed main()
{
int t = 1 ;
// t = read() ;
while(t -- ) {
solve() ;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3644kb
input:
3 1 2 2
output:
? 1 ? 2 ? 3 ! 3
result:
ok Correct position at 3
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3572kb
input:
10 1 0 1 0 1 1
output:
? 1 ? 6 ? 2 ? 5 ? 3 ? 5 ! 5
result:
wrong answer Wrong favorite light!