結果

問題 No.513 宝探し2
ユーザー 0w10w1
提出日時 2017-05-12 18:09:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,226 bytes
コンパイル時間 1,580 ms
コンパイル使用メモリ 172,876 KB
実行使用メモリ 24,336 KB
平均クエリ数 56.25
最終ジャッジ日時 2023-09-23 14:01:18
合計ジャッジ時間 3,459 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
23,640 KB
testcase_01 AC 27 ms
23,652 KB
testcase_02 AC 28 ms
24,024 KB
testcase_03 AC 28 ms
24,036 KB
testcase_04 AC 28 ms
23,532 KB
testcase_05 AC 27 ms
24,336 KB
testcase_06 RE -
testcase_07 AC 28 ms
23,568 KB
testcase_08 AC 24 ms
23,424 KB
testcase_09 AC 24 ms
24,204 KB
testcase_10 RE -
testcase_11 AC 26 ms
24,000 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int ask( int x, int t ) {
  static map< int, int > memo[ 2 ];
  if( memo[ t ].count( x ) ) {
    return memo[ t ][ x ];
  }
  if( t == 0 ) {
    cout << x << " " << 0 << endl;
  } else {
    cout << 0 << " " << x << endl;
  }
  cin >> memo[ t ][ x ];
  if( memo[ t ][ x ] == 0 ) {
    exit( 0 );
  }
  return memo[ t ][ x ];
}

signed main() {
  ios::sync_with_stdio( 0 );
  int ans[ 2 ];
  for( int t = 0; t < 2; ++t ) {
    int lb = 0, ub = int( 1e5 );
    while( ub - lb > 5 ) {
      int f = lb + ( ub - lb ) / 3;
      int g = lb + ( ub - lb ) * 2 / 3;
      int a = ask( lb, t );
      int b = ask( f, t );
      int c = ask( g, t );
      int d = ask( ub, t );
      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 {
        lb = g;
      }
    }
    int mind = int( 1e5 );
    for( int i = lb; i <= ub; ++i ) {
      int d = ask( i, t );
      if( d < mind ) {
        mind = d;
        ans[ t ] = i;
      }
    }
  }
  cout << ans[ 0 ] << " " << ans[ 1 ] << endl;
  int d;
  cin >> d;
  assert( d == 0 );
  return 0;
}
0