結果

問題 No.513 宝探し2
ユーザー 0w10w1
提出日時 2017-05-12 17:51:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,149 bytes
コンパイル時間 1,695 ms
コンパイル使用メモリ 175,276 KB
実行使用メモリ 24,372 KB
平均クエリ数 61.25
最終ジャッジ日時 2023-09-23 14:00:23
合計ジャッジ時間 4,105 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
23,568 KB
testcase_01 AC 28 ms
24,360 KB
testcase_02 WA -
testcase_03 AC 29 ms
23,412 KB
testcase_04 AC 29 ms
23,460 KB
testcase_05 AC 28 ms
23,400 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 26 ms
23,640 KB
testcase_09 AC 26 ms
23,676 KB
testcase_10 RE -
testcase_11 AC 27 ms
23,832 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:79:14: 警告: ‘ans_y’ may be used uninitialized [-Wmaybe-uninitialized]
   79 |   assert( ask( ans_x, ans_y ) == 0 );
      |              ^
main.cpp:16:14: 備考: ‘ans_y’ はここで定義されています
   16 |   int ans_x, ans_y;
      |              ^~~~~
main.cpp:79:14: 警告: ‘ans_x’ may be used uninitialized [-Wmaybe-uninitialized]
   79 |   assert( ask( ans_x, ans_y ) == 0 );
      |              ^
main.cpp:16:7: 備考: ‘ans_x’ はここで定義されています
   16 |   int ans_x, ans_y;
      |       ^~~~~

ソースコード

diff #

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

int ask( int x, int y ) {
  cout << x << " " << y << endl;
  int d;
  cin >> d;
  if( d == 0 ) {
    exit( 0 );
  }
  return d;
}

signed main() {
  ios::sync_with_stdio( 0 );
  int ans_x, ans_y;
  {
    map< int, int > memo;
    int lb = 0, ub = int( 1e5 );
    while( ub - lb > 5 ) {
      int f = lb + ( ub - lb ) / 3;
      int g = lb + ( ub - lb ) / 3 * 2;
      int a = memo[ lb ] = memo.count( lb ) ? memo[ lb ] : ask( lb, 0 );
      int b = memo[ f ] = memo.count( f ) ? memo[ f ] : ask( f, 0 );
      int c = memo[ g ] = memo.count( g ) ? memo[ g ] : ask( g, 0 );
      int d = memo[ ub ] = memo.count( ub ) ? memo[ ub ] : ask( ub, 0 );
      if( a <= b and b <= c and c <= d ) {
        ub = f;
      } else if( a >= b and b <= c and c <= d ) {
        ub = g;
      } else if( a >= b and b >= c and c <= d ) {
        lb = f;
      } else if( a >= b and b >= c and c >= d ) {
        lb = g;
      } else {
        assert( 0 );
      }
    }
    int mind = int( 1e5 );
    for( int i = lb; i <= ub; ++i ) {
      int d = ask( i, 0 );
      if( d < mind ) {
        mind = d;
        ans_x = i;
      }
    }
  }
  {
    map< int, int > memo;
    int lb = 0, ub = int( 1e5 );
    while( ub - lb > 5 ) {
      int f = lb + ( ub - lb ) / 3;
      int g = lb + ( ub - lb ) / 3 * 2;
      int a = memo[ lb ] = memo.count( lb ) ? memo[ lb ] : ask( 0, lb );
      int b = memo[ f ] = memo.count( f ) ? memo[ f ] : ask( 0, f );
      int c = memo[ g ] = memo.count( g ) ? memo[ g ] : ask( 0, g );
      int d = memo[ ub ] = memo.count( ub ) ? memo[ ub ] : ask( 0, ub );
      if( a <= b and b <= c and c <= d ) {
        ub = f;
      } else if( a >= b and b <= c and c <= d ) {
        ub = g;
      } else if( a >= b and b >= c and c <= d ) {
        lb = f;
      } else if( a >= b and b >= c and c >= d ) {
        lb = g;
      } else {
        assert( 0 );
      }
    }
    int mind = int( 1e5 );
    for( int i = lb; i <= ub; ++i ) {
      int d = ask( 0, i );
      if( d < mind ) {
        mind = d;
        ans_y = i;
      }
    }
  }
  assert( ask( ans_x, ans_y ) == 0 );
  return 0;
}
0