QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#218024 | #6394. Turn on the Light | CRN2010 | WA | 0ms | 3376kb | C++20 | 1.2kb | 2023-10-17 17:26:54 | 2023-10-17 17:26:54 |
Judging History
answer
#include <bits/stdc++.h>
#define int 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 = -1 , now ;
n = read() ;
int left = 1 , right = n ;
while(right >= left) {
int mid = (right+left)>>1;
cout << "? "<<mid<< endl ;
now = read() ;
if ( pre == -1 ) {
pre = now ;
continue ;
}
if ( now == pre ) {
cout << "! " << mid << endl ;
break ;
}
else if ( now > pre ) {
left = mid + 1 ;
}
else {
right = mid - 1 ;
}
pre = now ;
}
}
signed main()
{
int t = 1 ;
// t = read() ;
while(t -- ) {
solve() ;
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3376kb
input:
3 1 1
output:
? 2 ? 2 ! 2
result:
wrong answer Wrong favorite light!