Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <iostream>
- #include <string>
- #include <algorithm>
- #include <cmath>
- #include <vector>
- #include <stack>
- #include <queue>
- #include <list>
- #include <map>
- #include <set>
- #include <stdlib.h>
- #include <sstream>
- #include <assert.h>
- #include <memory.h>
- #include <complex>
- #include <time.h>
- #pragma comment(linker, "/STACK:100000000")
- using namespace std;
- #define mp make_pair
- #define pb push_back
- #define ll long long
- #define sz(x) (int)(x).size()
- bool vis[66][66][5][5][5];
- bool stop = false;
- int itt = 0;
- bool MOVE_LEFT() {
- if(stop) return false;
- cout << "MOVE LEFT" << endl;
- itt++;
- string s;
- cin >> s;
- if(s == "EXIT") {
- stop = true;
- return true;
- }
- if(s == "OK") {
- return true;
- }
- return false;
- }
- bool MOVE_RIGHT() {
- if(stop) return false;
- cout << "MOVE RIGHT" << endl;
- itt++;
- string s;
- cin >> s;
- if(s == "EXIT") {
- stop = true;
- return true;
- }
- if(s == "OK") {
- return true;
- }
- return false;
- }
- bool MOVE_DOWN() {
- if(stop) return false;
- cout << "MOVE DOWN" << endl;
- itt++;
- string s;
- cin >> s;
- if(s == "EXIT") {
- stop = true;
- return true;
- }
- if(s == "OK") {
- return true;
- }
- return false;
- }
- bool MOVE_UP() {
- if(stop) return false;
- cout << "MOVE UP" << endl;
- itt++;
- string s;
- cin >> s;
- if(s == "EXIT") {
- stop = true;
- return true;
- }
- if(s == "OK") {
- return true;
- }
- return false;
- }
- void go(int x, int y, int c1, int c2, int c3) {
- if(stop) return;
- if(vis[x][y][c1][c2][c3]) {
- cout << "BACK" << endl;
- itt++;
- string s;
- cin >> s;
- return;
- }
- vis[x][y][c1][c2][c3] = true;
- if(stop) return;
- if(!vis[x][y+1][c2][c3][1]) {
- if(MOVE_LEFT()) {
- if(stop) return;
- go(x, y + 1, c2, c3, 1);
- }
- }
- if(stop) return;
- if(!vis[x+1][y][c2][c3][2]) {
- if(MOVE_UP()) {
- if(stop) return;
- go(x + 1, y, c2, c3, 2);
- }
- }
- if(stop) return;
- if(!vis[x][y-1][c2][c3][3]) {
- if(MOVE_RIGHT()) {
- if(stop) return;
- go(x, y - 1, c2, c3, 3);
- }
- }
- if(stop) return;
- if(!vis[x-1][y][c2][c3][4]) {
- if(MOVE_DOWN()) {
- if(stop) return;
- go(x - 1, y, c2, c3, 4);
- }
- }
- if(stop) return;
- cout << "BACK" << endl;
- itt++;
- string s;
- cin >> s;
- }
- int main() {
- //freopen("palindrome.in","rt",stdin);
- //freopen("palindrome.out","wt",stdout);
- int N, M;
- scanf("%d %d", &N, &M);
- go(33, 33, 0, 0, 0);
- if(itt > 30000) assert(0);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement