結果

問題 No.513 宝探し2
ユーザー goodbatongoodbaton
提出日時 2017-05-29 19:31:36
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 1,170 bytes
コンパイル時間 762 ms
コンパイル使用メモリ 82,656 KB
実行使用メモリ 24,288 KB
平均クエリ数 63.42
最終ジャッジ日時 2023-09-24 01:18:50
合計ジャッジ時間 2,029 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
23,616 KB
testcase_01 AC 28 ms
23,352 KB
testcase_02 AC 27 ms
24,180 KB
testcase_03 AC 27 ms
23,580 KB
testcase_04 AC 28 ms
24,180 KB
testcase_05 AC 26 ms
23,520 KB
testcase_06 AC 27 ms
23,580 KB
testcase_07 AC 26 ms
23,400 KB
testcase_08 AC 26 ms
23,916 KB
testcase_09 AC 27 ms
23,736 KB
testcase_10 AC 28 ms
23,388 KB
testcase_11 AC 27 ms
24,288 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 = 0, y = 0;
  
  int l=0, r = 100000;
  
  while(l<r){
    int mid = (r+l)/2;
    
    if(mid == 100000 || query(x,mid) < query(x,mid+1)){
      r = mid;
    }else{
      l = mid+1;
    }
  }

  y = l;

  l=0; r = 100000;

  while(l<r){
    int mid = (r+l)/2;
    
    if(mid == 100000 || query(mid,y) < query(mid+1,y)){
      r = mid;
    }else{
      l = mid+1;
    }
  }
  
  x = l;

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