Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <cstdio>
- #include <cstring>
- #include <vector>
- #include <algorithm>
- #include <set>
- #include <map>
- #include <unordered_map>
- #include <unordered_set>
- #include <cmath>
- #include <ctime>
- #include <string>
- using namespace std;
- #ifdef LOCAL
- #define eprintf(...) fprintf(stderr, __VA_ARGS__)
- #else
- #define eprintf(...) 42
- #endif
- const int N = 30;
- int table[N][N];
- int n = 19;
- bool flag;
- int cntMove;
- int dx, dy;
- void init()
- {
- for (int x = 1; x <= n; x++)
- for (int y = 1; y <= n; y++)
- table[x][y] = -1;
- return;
- }
- void move(int x, int y)
- {
- if (flag)
- swap(x, y);
- if (table[x][y] != -1) return;
- table[x][y] = 1;
- cout << x << ' ' << y << endl;
- return;
- }
- void doSmart(int cntMove)
- {
- int x = 10, y = 10;
- while (table[x][y] == 0)
- {
- x += dx;
- y += dy;
- }
- move(x, y);
- dx *= -1;
- dy *= -1;
- return;
- }
- void makeMove(int cntMove)
- {
- int x, y;
- cin >> x >> y;
- if (x == -1 && y == -1)
- exit(0);
- table[x][y] = 0;
- if (cntMove == 2)
- {
- dx = x - 10;
- dy = y - 10;
- if (dx == 1 && dy == 1)
- {
- dx = -1;
- dy = -1;
- }
- }
- if (cntMove == 5)
- {
- if (x == 3 && y == 6)
- flag = true;
- }
- if (cntMove == 3 || cntMove == 4)
- {
- doSmart(cntMove);
- return;
- }
- if (cntMove == 1)
- move(5, 4);
- else if (cntMove == 2)
- move(4, 5);
- else if (cntMove == 5)
- move(3, 6);
- else if (cntMove == 6)
- move(3, 5);
- else if (cntMove == 7)
- move(3, 4);
- else if (cntMove == 8)
- move(5, 6);
- else if (cntMove == 9)
- move(5, 5);
- else if (cntMove == 10)
- move(4, 3);
- else if (cntMove == 11)
- move(6, 5);
- else if (cntMove == 12)
- move(7, 6);
- else if (cntMove == 13)
- {
- move(8, 7);
- move(3, 2);
- }
- else
- throw;
- }
- int main()
- {
- init();
- while(true)
- {
- cntMove++;
- makeMove(cntMove);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement