結果

問題 No.513 宝探し2
ユーザー aaaaaa
提出日時 2018-09-15 14:32:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,960 bytes
コンパイル時間 735 ms
コンパイル使用メモリ 92,636 KB
実行使用メモリ 24,348 KB
平均クエリ数 84.75
最終ジャッジ日時 2023-09-23 16:20:06
合計ジャッジ時間 3,876 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 24 ms
23,436 KB
testcase_07 AC 23 ms
23,328 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>

using namespace std;

int main() {
	int i, j, k;
	int x = 50000, y = 50000;
	int d;



		cout << x << " " << y << endl;

		cin >> d;

		if (d == 0) return 0;

		int add = 10000;
		int xx = x + add, yy = y;

		bool flag = false;   //falseで多くなってる trueで少なくなってる
		bool flag2 = true;   //falseでマイナスしている trueでプラスしている

		while (true)
		{
			bool first = true;
			cout << xx << " " << yy << endl;
			int dd;
			cin >> dd;

			if (dd == 0)return 0;

			if (dd > d) {
								

				if (flag2 == false) {
					xx += add;
					flag2 = true;
				}
				else if (flag2 == true) {
					xx -= add;
					flag2 = false;
				}
				flag = false;

				if (first != true)add /= 2;
				first = false;
			}
			else if(dd < d){

				if (flag2 == false) {
					xx -= add;
					flag2 = false;
				}
				else if (flag2 == true) {
					xx += add;
					flag2 = true;
				}
				flag = true;

			}
			else if (dd == d) {
				break;
			}

			d = dd;

		}


		while (true)
		{
			bool first = true;
			cout << xx << " " << yy << endl;
			int dd;
			cin >> dd;
			if (dd == 0) return 0;

			if (dd > d) {


				if (flag2 == false) {
					yy += add;
					flag2 = true;
				}
				else if (flag2 == true) {
					yy -= add;
					flag2 = false;
				}
				flag = false;

				if (first != true)add /= 2;
				first = false;
			}
			else if (dd < d) {

				if (flag2 == false) {
					yy -= add;
					flag2 = false;
				}
				else if (flag2 == true) {
					yy += add;
					flag2 = true;
				}
				flag = true;

			}
			else if (dd == d) {
				break;
			}

			d = dd;

		}







		return 0;



	getchar();
	getchar();
	return 0;
}
0