結果

問題 No.513 宝探し2
ユーザー aim_cpoaim_cpo
提出日時 2018-02-26 02:09:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,344 bytes
コンパイル時間 1,451 ms
コンパイル使用メモリ 165,768 KB
実行使用メモリ 24,300 KB
平均クエリ数 39.25
最終ジャッジ日時 2023-09-23 15:50:54
合計ジャッジ時間 3,969 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
24,264 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 24 ms
24,300 KB
testcase_09 AC 26 ms
23,376 KB
testcase_10 AC 26 ms
23,544 KB
testcase_11 AC 26 ms
23,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int main(){
  int minx=0,maxx=100000;
  cout<<minx<<" "<<0<<"\n";
  int d1;cin>>d1;
  if(d1==0)return 0;
  cout<<maxx<<" "<<0<<"\n";
  int d2;cin>>d2;
  if(d2==0)return 0;
  int leftdis=0,rightdis=0;
  if(d1>=d2){
    minx=(minx+maxx)/2;
    leftdis=0;
    rightdis=d2;
  }else{
    maxx=(minx+maxx)/2;
    leftdis=d1;
    rightdis=0;
  }
  int resx;
  while(maxx-minx>5){
    int mid=(minx+maxx)/2;
    cout<<mid<<" "<<0<<"\n";
    int d;cin>>d;
    if(d==0)return 0;
    if(leftdis==0){
      leftdis=d;
      if(leftdis>rightdis){
        leftdis=0;
        minx=mid;
      }else if(leftdis<rightdis){
        rightdis=0;
        maxx=mid;
      }else{
        resx=(maxx+minx)/2;
        break;
      }
    }else{
      rightdis=d;
      if(leftdis>rightdis){
        leftdis=0;
        minx=mid;
      }else if(leftdis<rightdis){
        rightdis=0;
        maxx=mid;
      }else{
        resx=(maxx+minx)/2;
        break;
      }
    }
  }
  resx=minx;
  int nowdis=999999999;
  for(int i=minx;i<=maxx;i++){
    cout<<i<<" "<<0<<"\n";
    int dd;cin>>dd;
    if(dd==0)return 0;
    if(dd<nowdis){
      nowdis=dd;
      resx=i;
    }
  }
  int miny=0,maxy=100000;
  cout<<resx<<" "<<miny<<"\n";
  d1;cin>>d1;
  if(d1==0)return 0;
  cout<<resx<<" "<<maxy<<"\n";
  d2;cin>>d2;
  if(d2==0)return 0;
  leftdis=0,rightdis=0;
  if(d1>=d2){
    miny=(miny+maxy)/2;
    leftdis=0;
    rightdis=d2;
  }else{
    maxy=(miny+maxy)/2;
    leftdis=d1;
    rightdis=0;
  }
  int resy;
  while(maxy-miny>5){
    int mid=(miny+maxy)/2;
    cout<<resx<<" "<<mid<<"\n";
    int d;cin>>d;
    if(d==0)return 0;
    if(leftdis==0){
      leftdis=d;
      if(leftdis>rightdis){
        leftdis=0;
        miny=mid;
      }else if(leftdis<rightdis){
        rightdis=0;
        maxy=mid;
      }else{
        resy=(maxy+miny)/2;
        cout<<resx<<" "<<resy<<"\n";
        int dd;cin>>dd;
        if(dd==0)return 0;
        break;
      }
    }else{
      rightdis=d;
      if(leftdis>rightdis){
        leftdis=0;
        miny=mid;
      }else{
        rightdis=0;
        maxy=mid;
      }
    }
  }
  resy=miny;
  nowdis=999999999;
  for(int i=miny;i<=maxy;i++){
    cout<<resx<<" "<<i<<"\n";
    int dd;cin>>dd;
    if(dd==0)return 0;
    if(dd<nowdis){
      nowdis=dd;
      resy=i;
    }
  }
  return 0;
}
0