QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#162917 | #5206. Hot and Cold | karuna# | WA | 1ms | 3672kb | C++17 | 3.8kb | 2023-09-03 17:43:42 | 2023-09-03 17:43:43 |
Judging History
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 = 20001;
// 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 = 1, ex = 1000000;
int p = 0;
while (sx < ex) {
int k = (ex - sx + 1) / 3;
if (ex - sx == 1) {
if (p == sx - 1) {
string s = ask(ex, 0);
if (mp.find(s) == mp.end()) ex = sx;
else sx = ex;
}
else {
string s = ask(sx, 0);
if (mp.find(s) == mp.end()) sx = ex;
else ex = sx;
}
break;
}
if (p == sx - 1) {
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 + 1;
}
else {
ex = p - 1;
}
}
else if (mp[s] == 2) {
ask(p - k, 0);
p -= k;
ex = p - 1;
}
}
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 - 1;
}
else {
sx = p + 1;
}
}
else if (mp[s] == 2) {
ask(p + k, 0);
p += k;
sx = p + 1;
}
}
}
int sy = 1, ey = 1000000;
p = 0;
while (sy < ey) {
int k = (ey - sy + 1) / 3;
if (ey - sy == 1) {
if (p == sy - 1) {
string s = ask(sx, ey);
if (mp.find(s) == mp.end()) ey = sy;
else sy = ey;
}
else {
string s = ask(sx, sy);
if (mp.find(s) == mp.end()) sy = ey;
else ey = sy;
}
break;
}
if (p == sy - 1) {
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 + 1;
}
else {
ey = p - 1;
}
}
else if (mp[s] == 2) {
ask(sx, p - k);
p -= k;
ey = p - 1;
}
}
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 - 1;
}
else {
sy = p + 1;
}
}
else if (mp[s] == 2) {
ask(sx, p + k);
p += k;
sy = p + 1;
}
}
}
ask(sx, sy);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3672kb
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