結果

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

テストケース

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

ソースコード

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) {
					if (xx + add <= 100000) {
						xx += add;
					}
					else {
						while (true) {
							add /= 2;
							if (xx + add <= 100000) {
								xx += add;
								break;
							}
						}
					}
					flag2 = true;
				}
				else if (flag2 == true) {
					//xx -= add;
					if (xx - add >= 0) {
						xx -= add;
					}
					else {
						while (true) {
							add /= 2;
							if (xx - add >= 0) {
								xx -= add;
								break;
							}
						}
					}
					flag2 = false;
				}
				flag = false;

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

				if (flag2 == false) {
//					xx -= add;
					if (xx - add >= 0) {
						xx -= add;
					}
					else {
						while (true) {
							add /= 2;
							if (xx - add >= 0) {
								xx -= add;
								break;
							}
						}
					}
					flag2 = false;
				}
				else if (flag2 == true) {
					//xx += add;
					if (xx + add <= 100000) {
						xx += add;
					}
					else {
						while (true) {
							add /= 2;
							if (xx + add <= 100000) {
								xx += add;
								break;
							}
						}
					}
					flag2 = true;
				}
				flag = true;

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

			d = dd;

		}

		add = 10000;
		yy += add;
		//cout << xx << " " << yy << endl;
		flag2 = 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) {
					if (yy + add <= 100000) {
						yy += add;
					}
					else {
						while (true) {
							add /= 2;
							if (yy + add <= 100000) {
								yy += add;
								break;
							}
						}
					}
					flag2 = true;
				}
				else if (flag2 == true) {
					//yy -= add;
					if (yy - add >= 0) {
						yy -= add;
					}
					else {
						while (true) {
							add /= 2;
							if (yy - add >= 0) {
								yy -= add;
								break;
							}
						}
					}
					flag2 = false;
				}
				flag = false;

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

				if (flag2 == false) {
					//yy -= add;
					if (yy - add >= 0) {
						yy -= add;
					}
					else {
						while (true) {
							add /= 2;
							if (yy - add >= 0) {
								yy -= add;
								break;
							}
						}
					}
					flag2 = false;
				}
				else if (flag2 == true) {
					//yy += add;
					if (yy + add <= 100000) {
						yy += add;
					}
					else {
						while (true) {
							add /= 2;
							if (yy + add <= 100000) {
								yy += add;
								break;
							}
						}
					}
					flag2 = true;
				}
				flag = true;

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

			d = dd;

		}







		return 0;



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