#include #include #include #include using namespace std; const int D1[] = {0, 1, 0, -1}, D2[] = {1, 0, -1, 0}; const int SZ[] = {2, 3, 3, 4, 5}; const int SUM = 2 + 3 + 3 + 4 + 5; int hits = 0, myhits = 0; bool is[12][12]; bool cell[12][12], iscell[12][12]; char MSG[24]; int main() { srand(time(0)); int xcoord = 1; for (int size = 1; size <= 5; ++size) { cout << xcoord << ' ' << 3 << ' ' << 0 << '\n'; for (int j = 0; j < SZ[size - 1]; ++j) is[xcoord][3 + j] = true; cout.flush(); xcoord += 2; } while (true) { bool any = false; /*for (int xn = 1; xn <= 10 && !any; ++xn) for (int yn = 1; yn <= 10 && !any; ++yn) if (iscell[xn][yn]) { for (int k = 0; k < 4 && !any; ++k) if (xn + D1[k] >= 1 && xn + D1[k] <= 10 && yn + D2[k] >= 1 && yn + D2[k] <= 10 && !cell[xn + D1[k]][yn + D2[k]]) { xn += D1[k]; yn += D2[k]; cout << xn << ' ' << yn << '\n'; cout.flush(); cell[xn][yn] = true; cin >> MSG; if (MSG[0] == 'H') { iscell[xn][yn] = true; ++hits; } else if (MSG[0] == 'S') { iscell[xn][yn] = true; cin >> MSG; ++hits; } any = true; } }*/ for (int xn = 1; xn <= 10 && !any; ++xn) for (int yn = 1; yn <= 10 && !any; ++yn) if (!cell[xn][yn]) { cout << xn << ' ' << yn << '\n'; cout.flush(); cell[xn][yn] = true; cin >> MSG; if (MSG[0] == 'H') { iscell[xn][yn] = true; ++hits; } else if (MSG[0] == 'S') { iscell[xn][yn] = true; cin >> MSG; ++hits; } any = true; } if (hits == SUM) break; int xh, yh; cin >> xh >> yh; if (is[xh][yh]) ++myhits; if (myhits == SUM) break; } }