結果
| 問題 | 
                            No.513 宝探し2
                             | 
                    
| コンテスト | |
| ユーザー | 
                             aim_cpo
                         | 
                    
| 提出日時 | 2018-02-26 02:48:19 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 30 ms / 2,000 ms | 
| コード長 | 786 bytes | 
| コンパイル時間 | 1,681 ms | 
| コンパイル使用メモリ | 168,084 KB | 
| 実行使用メモリ | 25,220 KB | 
| 平均クエリ数 | 22.58 | 
| 最終ジャッジ日時 | 2024-07-16 15:37:20 | 
| 合計ジャッジ時間 | 3,012 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 12 | 
ソースコード
#include<bits/stdc++.h>
using namespace std;
inline int check(int minx,int maxx){
  cout<<minx<<" "<<0<<"\n";
  int d1;cin>>d1;
  if(d1==0)return -1;
  cout<<maxx<<" "<<0<<"\n";
  int d2;cin>>d2;
  if(d2==0)return -1;
  if(d1==d2)return 0;
  else if(d1>d2)return 2;
  else return 1;
}
int main(){
  int minx=0,maxx=100000;
  int resx=0;
  bool flag=0;
  while(maxx-minx>1){
    int temp=check(minx,maxx);
    if(temp==-1)return 0;
    else if(temp==0){
      resx=(minx+maxx)/2;
      flag=1;
      break;
    }else if(temp==1){
      maxx=(minx+maxx)/2;
    }else{
      minx=(minx+maxx)/2;
    }
  }
  if(!flag){
    int temp=check(minx,maxx);
    if(temp==1)resx=minx;
    else resx=maxx;
  }
  cout<<resx<<" "<<0<<endl;
  int dd;cin>>dd;
  cout<<resx<<" "<<dd<<endl;
  return 0;
}
            
            
            
        
            
aim_cpo