結果
問題 | No.253 ロウソクの長さ |
ユーザー |
![]() |
提出日時 | 2015-07-24 23:14:25 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 28 ms / 2,000 ms |
コード長 | 748 bytes |
コンパイル時間 | 576 ms |
コンパイル使用メモリ | 65,412 KB |
実行使用メモリ | 25,476 KB |
平均クエリ数 | 21.11 |
最終ジャッジ日時 | 2024-07-16 20:49:05 |
合計ジャッジ時間 | 3,633 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 36 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:54:13: warning: ‘rez’ may be used uninitialized in this function [-Wmaybe-uninitialized] 54 | cout<<"! "<<rez<<endl; | ^~~
ソースコード
#include <iostream>#include <cstdio>#include <cmath>#include <utility>#include <algorithm>#include <vector>#include <cstring>#define _P(x) printf(x);#define ALL(a) (a.begin()),(a.end())#define ZERO(a) memset(a,0,sizeof(a))#define MINUS(a) memset(a,0xff,sizeof(a))using namespace std;typedef vector<int> vi;typedef pair<int,int> ii;typedef long long ll;int main(){int sec=0;int l=10,r=1e9;int rez;int a;cout<<"? 101"<<endl;cin>>a;if(a==-1)r=100;else if(a==0){cout<<"! "<<101<<endl;return 0;}else l=102;sec++;while(l<=r){int mid=(l+r)/2-sec;cout<<"? "<<mid<<endl;cin>>a;if(a==0){rez=mid+sec;break;}if(a==1){l=mid+sec+1;rez=mid+sec;}if(a==-1)r=mid+sec-1;sec++;}cout<<"! "<<rez<<endl;return 0;}