QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#162888 | #5206. Hot and Cold | karuna# | WA | 2ms | 3836kb | C++17 | 4.4kb | 2023-09-03 17:22:17 | 2023-09-03 17:22:17 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
map<string, int> mp;
map<pair<int, int>, string> cache;
// string message[5] = {
// "found!",
// "closer",
// "further",
// "same",
// "not found"
// };
// int _x = 2;
// int _y = 2;
// 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;
// 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);
ask(1, 0);
ask(0, 1);
mp[s2] = 1; // closer
ask(1, 1);
string s3 = ask(0, 0);
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;
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;
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: 2ms
memory: 3836kb
input:
Tabilmadi Daha yakin Dalej Dalej Dalej Dalej
output:
0 0 1 1 1 0 0 1 666666 0 333333 666666
result:
wrong answer format Unexpected end of file - int32 expected