結果

問題 No.594 壊れた宝物発見機
ユーザー ukohank517ukohank517
提出日時 2017-11-11 00:10:01
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 110 ms / 2,000 ms
コード長 2,202 bytes
コンパイル時間 765 ms
コンパイル使用メモリ 91,228 KB
実行使用メモリ 24,492 KB
平均クエリ数 46.30
最終ジャッジ日時 2023-09-23 15:00:30
合計ジャッジ時間 4,006 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 110 ms
23,676 KB
testcase_01 AC 98 ms
24,492 KB
testcase_02 AC 99 ms
24,276 KB
testcase_03 AC 100 ms
24,036 KB
testcase_04 AC 102 ms
24,036 KB
testcase_05 AC 99 ms
23,652 KB
testcase_06 AC 102 ms
24,372 KB
testcase_07 AC 100 ms
23,640 KB
testcase_08 AC 99 ms
23,640 KB
testcase_09 AC 98 ms
24,252 KB
testcase_10 AC 99 ms
23,544 KB
testcase_11 AC 99 ms
23,820 KB
testcase_12 AC 99 ms
24,060 KB
testcase_13 AC 99 ms
24,348 KB
testcase_14 AC 98 ms
24,060 KB
testcase_15 AC 97 ms
23,676 KB
testcase_16 AC 99 ms
23,868 KB
testcase_17 AC 99 ms
24,264 KB
testcase_18 AC 99 ms
24,252 KB
testcase_19 AC 97 ms
24,036 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}

// 質問クエリ
int ask(int x, int y, int z) {
  int d;
  cout << "?" << " " << x << " " << y << " " << z << endl;
  cin >> d;
  return d;
}

// 回答クエリ
void answer(int x, int y, int z) {
  cout << "!" << " " << x << " " << y << " " << z << endl;
}


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int minx = -150, maxx = 150;
  int miny = -150, maxy = 150;
  int minz = -150, maxz = 150;
  
  int x=-150,y=-150,z=-150;
  

  //xについて
  while(minx<maxx){
    int left = minx, middle = (minx+maxx)/2, right = maxx;

    ll ansl, ansr;
    ansl = ask((left+middle)/2,y,z);
    
    ansr = ask((middle+right)/2,y,z);
  
    if(ansl<ansr) maxx = middle;
    else minx = middle;
    if (ansl==ansr) break; 
  }
  x = minx;

    //yについて
  while(miny<maxy){
    int left = miny, middle = (miny+maxy)/2, right = maxy;

    ll ansl, ansr;
    ansl = ask(x,(left+middle)/2,z);
    
    ansr = ask(x,(middle+right)/2,z);
  
    if(ansl<ansr) maxy = middle;
    else miny = middle;
    if (ansl==ansr) break; 
  }
  y = miny;
  
  //zについて
  while(minz<maxz){
    int left = minz, middle = (minz+maxz)/2, right = maxz;

    ll ansl, ansr;
    ansl = ask(x,y,(left+middle)/2);
    
    ansr = ask(x,y,(middle+right)/2);
  
    if(ansl<ansr) maxz = middle;
    else minz = middle;
    if (ansl==ansr) break; 
  }
  z = minz;

  answer(x,y,z);
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}
0