QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#162899#5206. Hot and Coldkaruna#WA 1ms3504kbC++174.5kb2023-09-03 17:27:422023-09-03 17:27:43

Judging History

你现在查看的是最新测评结果

  • [2023-09-03 17:27:43]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3504kb
  • [2023-09-03 17:27:42]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

map<string, int> mp;

map<pair<int, int>, string> cache;

// string message[5] = {
// 	"fo u nd   !",
// 	"cl o  ser",
// 	"fu  the r",
// 	"s am    e",
// 	"no t f ou n d"
// };

// int _x = 20001;
// int _y = 20000;

// int px = -1;
// int py = -1;
// int cnt = 0;
string ask(int x, int y) {
	// ++cnt;
	// cout << x << ' ' << y << endl;
	// if (px == -1) {
	// 	px = x;
	// 	py = y;
	// 	cout << message[4] << endl;
	// 	return message[4];
	// }
	// if (x == _x && y == _y) {
	// 	cout << message[0] << endl;
	// 	cout << cnt << '\n';
	// 	exit(0);
	// 	return message[0];
	// }

	// long long d1 = (long long)(_x - px) * (_x - px) + (long long)(_y - py) * (_y - py);
	// long long d2 = (long long)(_x - x) * (_x - x) + (long long)(_y - y) * (_y - y);
	// px = x;
	// py = y;
	// if (d1 == d2) {
	// 	cout << message[3] << endl;
	// 	return message[3];
	// }
	// if (d1 < d2) {
	// 	cout << message[2] << endl;
	// 	return message[2];
	// }
	// if (d1 > d2) {
	// 	cout << message[1] << endl;
	// 	return message[1];
	// }
	// return "";

	if (cache.find({x, y}) != cache.end()) {
		return cache[{x, y}];
	}
	string s;
	cout << x << ' ' << y << endl;
	getline(cin, s);
	if (s[(int)s.size() - 1] == '!') {
		exit(0);
	}
	cache[{x, y}] = s;
	return s;
}
int main() {
	string s1 = ask(0, 0);
	mp[s1] = 0; // not found
	string s2 = ask(1, 1);
	string s3 = ask(0, 0);

	if (s2 == s3) {
		ask(1, 0);
		ask(0, 1);
	}
	else {
		mp[s2] = 1; // closer;
		mp[s3] = 2; // further;
	}

	int sx = 0, ex = 1000000;
	int p = 0;
	while (sx < ex) {
		int k = (ex - sx + 1) / 3;
		if (ex - sx == 1) {
			if (p == sx) {
				string s = ask(ex, 0);
				if (mp[s] == 1) sx = ex;
				else ex = sx;
			}
			else {
				string s = ask(sx, 0);
				if (mp[s] == 1) ex = sx;
				else sx = ex;
			}
			break;
		}
		if (ex - sx == 2) {
			if (p == sx) {
				string s = ask(ex, 0);
				if (mp.find(s) == mp.end()) sx = ex = (sx + ex) / 2;
				else if (mp[s] == 1) sx = ex;
				else ex = sx;
			}
			else {
				string s = ask(sx, 0);
				if (mp.find(s) == mp.end()) sx = ex = (sx + ex) / 2;
				else if (mp[s] == 1) ex = sx;
				else sx = ex;
			}
			break;
		}
		if (p == sx) {
			string s = ask(p + 2 * k, 0);
			p += 2 * k;
			if (mp.find(s) == mp.end()) { // same
				sx = ex = p - k;
				break;
			}
			else if (mp[s] == 1) {
				string t = ask(p + 1, 0);
				p += 1;
				if (mp[t] == 1) {
					sx = p;
				}
				else {
					ex = p;
				}
			}
			else if (mp[s] == 2) {
				ask(p - k - 1, 0);
				p -= k + 1;
				ex = p;
			}
		}
		else {
			string s = ask(p - 2 * k, 0);
			p -= 2 * k;
			if (mp.find(s) == mp.end()) { // same
				sx = ex = p + k;
				break;
			}
			else if (mp[s] == 1) {
				string t = ask(p - 1, 0);
				p -= 1;
				if (mp[t] == 1) {
					ex = p;
				}
				else {
					sx = p;
				}
			}
			else if (mp[s] == 2) {
				ask(p + k + 1, 0);
				p += k + 1;
				sx = p;
			}
		}
	}
	int sy = 0, ey = 1000000;
	p = 0;
	while (sy < ey) {
		int k = (ey - sy + 1) / 3;
		if (ey - sy == 1) {
			if (p == sy) {
				string s = ask(sx, ey);
				if (mp[s] == 1) sy = ey;
				else ey = sy;
			}
			else {
				string s = ask(sx, sy);
				if (mp[s] == 1) ey = sy;
				else sy = ey;
			}
			break;
		}
		if (ey - sy == 2) {
			if (p == sy) {
				string s = ask(sx, ey);
				if (mp.find(s) == mp.end()) sy = ey = (sy + ey) / 2;
				else if (mp[s] == 1) sy = ey;
				else ey = sy;
			}
			else {
				string s = ask(sx, sy);
				if (mp.find(s) == mp.end()) sy = ey = (sy + ey) / 2;
				else if (mp[s] == 1) ey = sy;
				else sy = ey;
			}
			break;
		}
		if (p == sy) {
			string s = ask(sx, p + 2 * k);
			p += 2 * k;
			if (mp.find(s) == mp.end()) { // same
				sy = ey = p - k;
				break;
			}
			else if (mp[s] == 1) {
				string t = ask(sx, p + 1);
				p += 1;
				if (mp[t] == 1) {
					sy = p;
				}
				else {
					ey = p;
				}
			}
			else if (mp[s] == 2) {
				ask(sx, p - k - 1);
				p -= k + 1;
				ey = p;
			}
		}
		else {
			string s = ask(sx, p - 2 * k);
			p -= 2 * k;
			if (mp.find(s) == mp.end()) { // same
				sy = ey = p + k;
				break;
			}
			else if (mp[s] == 1) {
				string t = ask(sx, p - 1);
				p -= 1;
				if (mp[t] == 1) {
					ey = p;
				}
				else {
					sy = p;
				}
			}
			else if (mp[s] == 2) {
				ask(sx, p + k + 1);
				p += k + 1;
				sy = p;
			}
		}
	}
	ask(sx, sy);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3504kb

input:

Tabilmadi
Daha yakin
Dalej
Dalej
Daha yakin

output:

0 0
1 1
666666 0
333333 666666
333333 333333

result:

wrong answer format  Unexpected end of file - int32 expected