結果

問題 No.513 宝探し2
ユーザー tnakao0123tnakao0123
提出日時 2017-05-14 21:51:21
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 32 ms / 2,000 ms
コード長 1,072 bytes
コンパイル時間 526 ms
コンパイル使用メモリ 81,304 KB
実行使用メモリ 24,288 KB
平均クエリ数 2.75
最終ジャッジ日時 2023-09-24 01:15:59
合計ジャッジ時間 1,892 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
23,328 KB
testcase_01 AC 25 ms
24,252 KB
testcase_02 AC 25 ms
24,288 KB
testcase_03 AC 25 ms
23,400 KB
testcase_04 AC 25 ms
24,240 KB
testcase_05 AC 25 ms
23,748 KB
testcase_06 AC 25 ms
23,292 KB
testcase_07 AC 25 ms
23,964 KB
testcase_08 AC 26 ms
23,952 KB
testcase_09 AC 25 ms
23,580 KB
testcase_10 AC 26 ms
23,952 KB
testcase_11 AC 26 ms
23,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 513.cc: No.513 宝探し2 - yukicoder
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int N = 100000;

/* typedef */

/* global variables */

/* subroutines */

int reqres(int x, int y) {
  printf("%d %d\n", x, y); fflush(stdout);
  int r;
  scanf("%d", &r);
  return r;
}

/* main */

int main() {
  int r0 = reqres(0, 0); // x + y = r0
  if (r0 == 0) return 0;
  int r1 = reqres(N, 0); // y = x - (N - r1)
  if (r1 == 0) return 0;

  // x + y = r0 ..(1)
  // y = x - (N - r1) -> x - y = (N - r1) ..(2)
  // (1)+(2) -> 2*x = r0 - r1 + N -> x = (r0 - r1 + N) /2
  // (1)-(2) -> 2*y = r0 + r1 - N -> y = (r0 + r1 - N) /2

  int x = (r0 - r1 + N) / 2, y = (r0 + r1 - N) / 2;
  printf("%d %d\n", x, y); fflush(stdout);
  return 0;
}
0