結果
問題 |
No.3212 SUPER Guess the Number
|
ユーザー |
![]() |
提出日時 | 2025-07-25 22:27:30 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 29 ms / 2,000 ms |
コード長 | 1,211 bytes |
コンパイル時間 | 4,243 ms |
コンパイル使用メモリ | 251,240 KB |
実行使用メモリ | 25,844 KB |
平均クエリ数 | 22.75 |
最終ジャッジ日時 | 2025-07-25 22:27:37 |
合計ジャッジ時間 | 5,701 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 12 |
ソースコード
#include <stdio.h> #include <atcoder/all> #include <bits/stdc++.h> using namespace std; using namespace atcoder; using mint = modint998244353; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf32 1000000005 #define Inf64 1000000000000000001LL int query(long long x, bool f =true){ cout<<"? "<<x<<endl; if(!f)return 0; int res; cin>>res; if(res==-1)assert(false); return res; } pair<long long,long long> get(int res,long long last,long long cur){ long long d = (abs(last-cur)) / 2; if(res==1){ if(last < cur){ return {cur-d, Inf64}; } else{ return {-Inf64, cur+d}; } } else{ d = (abs(last-cur)-1)/2; if(last < cur){ return {-Inf64, last+d}; } else{ return {last-d, Inf64}; } } } int main(){ long long last = -Inf64; long long l = 1,r = 1000000; while(l!=r){ if(last==-Inf64){ query(l, false); last = l; } else{ long long mid = (l+r)/2; long long cur = mid*2 - last; if(cur < last)cur--; else cur++; if(abs(cur) > 1000000000){ last = -Inf64; continue; } int res = query(cur); auto p = get(res, last, cur); l = max(l,p.first); r = min(r,p.second); last = cur; } } cout<<"! "<<l<<endl; return 0; }