QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#378378 | #6394. Turn on the Light | RainbowX# | WA | 1ms | 3688kb | C++20 | 1.8kb | 2024-04-06 12:21:52 | 2024-04-06 12:21:52 |
Judging History
answer
#pragma GCC optimize(3)
#include <bits/stdc++.h>
#define f(i, n, m) for (long long i = n; i <= m; ++i)
#define unf(i, n, m) for (long long i = n; i >= m; --i)
#define kong NULL
#define debug cout << "sss" << endl;
using ll = long long;
using ull = unsigned long long;
using point_t = double; // 计算几何的默认类型
const double e = exp(1.0);
const double pi = acos(-1.0);
constexpr ll inf = 0x3f3f3f3f3f3f3f3f;
constexpr ll maxx = 0x3f3f3f3f3f3f3f3f;
constexpr ll minn = 0xc0c0c0c0c0c0c0c0;
// #define endl '\n'
constexpr char blank = ' ';
constexpr ll mod = (ll)998244353;
constexpr size_t N = (size_t)1e6 + 6;
#ifdef _DEBUG
#define Crash(...) (__debugbreak(), 0)
#define Debug(...) (__debugbreak(), 0)
#else
#define Crash(...) (exit(-1), 0)
#define Debug(...) ((void)0)
#endif // _DEBUG
#define ensure(expression) (void)(!!(expression) || Crash())
inline void setaccuracy(const std::streamsize &accuracy)
{
std::cout << std::fixed << std::setprecision(accuracy);
}
#define int long long
using namespace std;
void solve()
{
int n;
cin>>n;
int l=1,r=1;
int jue=0;
f(i,1,min(n,(int)20)){
cout<<"? "<<i<<endl;
int a;
cin>>a;
if(a==jue){
cout<<"! "<<a<<endl;
return;
}
jue=a;
}
l=21;
while(l<=r){
int mid=l+r>>1;
cout<<"? "<<mid<<endl;
int a;
cin>>a;
if(a>jue){
l=mid+1;
}
else if(a<jue){
r=mid-1;
}
else {
cout<<"! "<<mid<<endl;
return;
}
}
// std::cout<< minn<<endl;
}
signed main()
{
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cout.tie(nullptr);
int T = 1;
// cin >> T;
// scanf(" %d", &T);
// std::cin >> T;
// for (int q = 1; q <= T; q++) {
// while (T--) {
solve();
// }
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3688kb
input:
3 1 2 2
output:
? 1 ? 2 ? 3 ! 2
result:
wrong answer Wrong favorite light!