- P8's solution
P8's Solution
- 2025-9-4 21:59:15 @
直接分 种情况大力分类讨论即可。当然了,直接这么写的话,代码会很长;因此,我们可以以 和 为分界线,将 种情况等分成 份,这样就只需要对 种情况分类讨论了。
#include <bits/stdc++.h>
using namespace std;
int dx, dy, res;
bool first()
{
cout << "3 3" << endl;
cin >> res;
if (res == 2) return true;
if (res == 1)
{
dx = 3;
dy = 3;
return false;
}
cout << "3 6" << endl;
cin >> res;
if (res == 2) return true;
if (res == 1)
{
dx = 3;
dy = 6;
return false;
}
cout << "6 3" << endl;
cin >> res;
if (res == 2) return true;
if (res == 1)
{
dx = 6;
dy = 3;
return false;
}
dx = 6;
dy = 6;
return false;
}
bool go()
{
if (first()) return true;
cout << dx + 1 << ' ' << dy + 1 << endl;
cin >> res;
if (res == 2) return true;
if (res == 1)
{
cout << dx + 1 << ' ' << dy - 1 << endl;
cin >> res;
if (res == 0)
{
cout << dx << ' ' << dy + 1 << endl;
cin >> res;
return true;
}
cout << dx << ' ' << dy << endl;
cin >> res;
if (res == 2) return true;
cout << dx + 1 << ' ' << dy << endl;
cin >> res;
return true;
}
else
{
cout << dx << ' ' << dy - 2 << endl;
cin >> res;
if (res == 0)
{
cout << dx - 1 << ' ' << dy << endl;
cin >> res;
if (res == 2) return true;
cout << dx - 1 << ' ' << dy + 1 << endl;
cin >> res;
return true;
}
cout << dx + 1 << ' ' << dy - 1 << endl;
cin >> res;
if (res == 2) return true;
if (res == 0)
{
cout << dx - 1 << ' ' << dy - 1 << endl;
cin >> res;
return true;
}
cout << dx << ' ' << dy - 1 << endl;
cin >> res;
return true;
}
}
int main()
{
int T;
cin >> T;
while (T--) go();
return 0;
}