#include<bits/stdc++.h> using namespace std; char map1[503][503]; int minx, maxy, maxx, miny; int main() { for (int i = 1; i <= 502; i++) { for (int j = 1; j <= 502; j++) { map1[i][j] = '*'; } } string fx; string choose, choose2 = "FAIL", choose3 = "SUCC"; string N = "N", W = "W", S = "S", E = "E"; int x = 200, y = 200; map1[200][200] = '.'; map1[199][199] = '#'; map1[199][200] = '#'; map1[199][201] = '#'; map1[200][199] = '#'; map1[200][201] = '#'; map1[201][199] = '#'; map1[201][200] = '#'; map1[201][201] = '#'; int s = 0; minx = x - 1; miny = y - 1; maxx = x + 1; maxy = y + 1; while(1) { int nox = x, noy = y; cout << "LEFT" << endl; cin >> choose; fx = choose; cout << "GO" << endl; cin >> choose; if (choose == choose2) { if (fx == N) map1[x - 1][y] = '#', nox--; if (fx == W) map1[x][y - 1] = '#', noy--; if (fx == S) map1[x + 1][y] = '#', nox++; if (fx == E) map1[x][y + 1] = '#', noy++; s++; } else { s = 0; if (fx == N) map1[x - 1][y] = '.', x--; if (fx == W) map1[x][y - 1] = '.', y--; if (fx == S) map1[x + 1][y] = '.', x++; if (fx == E) map1[x][y + 1] = '.', y++; } minx = min(x, minx); maxx = max(x, maxx); miny = min(y, miny); maxy = max(y, maxy); minx = min(x, nox); maxx = max(x, nox); miny = min(y, noy); maxy = max(y, noy); if (s == 4 || ((s == 3) && (map1[x + 1][y] == '.' || map1[x - 1][y] == '.' || map1[x][y + 1] == '.' || map1[x][y - 1] == '.'))) { cout << "END" << endl; cout << maxx - minx + 1 << " " << maxy - miny + 1 << endl; for (int i = minx; i <= maxx; i++) { for (int j = miny; j <= maxy; j++) { if (map1[i][j] == '*') map1[i][j] = '#'; cout << map1[i][j]; } cout << endl; } return 0; } } return 0; }