結果

問題 No.514 宝探し3
ユーザー goodbatongoodbaton
提出日時 2017-05-29 19:38:37
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 1,068 bytes
コンパイル時間 592 ms
コンパイル使用メモリ 82,624 KB
実行使用メモリ 24,372 KB
平均クエリ数 3.50
最終ジャッジ日時 2023-09-23 14:11:09
合計ジャッジ時間 1,787 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
24,096 KB
testcase_01 AC 23 ms
23,580 KB
testcase_02 AC 25 ms
23,460 KB
testcase_03 AC 24 ms
23,928 KB
testcase_04 AC 23 ms
23,580 KB
testcase_05 AC 22 ms
23,880 KB
testcase_06 AC 23 ms
23,424 KB
testcase_07 AC 23 ms
24,072 KB
testcase_08 AC 22 ms
23,436 KB
testcase_09 AC 23 ms
24,372 KB
testcase_10 AC 23 ms
23,472 KB
testcase_11 AC 23 ms
23,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


map<pair<int,int>, int> memo;

int query(int x, int y){
  if(memo.find({x,y})!=memo.end()){
    return memo[make_pair(x,y)];
  }
  
  cout << x << " " << y << endl;
  int res;
  
  cin >> res;
  
  return memo[make_pair(x,y)] = res;
}

int main(){
  int x,y;
  int q1,q2;
  int res1, res2;
  int t1,t2;
  
  res1 = query(0,0);
  res2 = query(0,1000000000);

  t1 = abs(res1-res2);
  t2 = 1000000000;
  
  q1 = (t1 + t2)/2;
  q2 = abs(t1 - t2)/2;

  if(res1 < res2){
    y = min(q1,q2);
  }else{
    y = max(q1,q2);
  }

  x = query(0,y);
  
  query(x,y);
  
  return 0;
}
0