Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define TASKNAME "chess"
- #include <cstdio>
- #include <iostream>
- #include <fstream>
- #include <cmath>
- #include <algorithm>
- #include <ctime>
- #include <cctype>
- #include <cstdlib>
- #include <cassert>
- #include <functional>
- #include <iomanip>
- #include <string>
- #include <cstring>
- #include <map>
- #include <set>
- #include <vector>
- #define EPS (1e-9)
- #define INF (int(1e9))
- #define INFLONG ((long long)(1e18))
- #define sqr(a) ((a) * (a))
- #define all(a) (a).begin(), (a).end()
- #define zero(a) memset(a, 0, sizeof(a))
- #define abs(a) (((a) < 0) ? -(a) : (a))
- #define sz(a) (int)a.size()
- #define fst first
- #define snd second
- #define y1 osrughosduvgarligybakrybrogvba
- #define y0 aosfigdalrowgyalsouvgrlvygalri
- #define mp make_pair
- #define pb push_back
- #define next dlkjdslfkdj
- #define prev dsdflksdfjl
- #define hash lkdfjldskfj
- #define pi 3.1415926535897932384626433832795
- #define eprintf(...) fprintf(stderr, __VA_ARGS__)
- using namespace std;
- typedef long long ll;
- typedef long double ld;
- typedef vector <int> vi;
- typedef vector <vi> vvi;
- typedef vector <bool> vb;
- typedef vector <ll> vll;
- typedef pair <int, int> pii;
- typedef pair <ll, ll> pll;
- typedef pair <ll, int> pli;
- typedef pair <int, ll> pil;
- typedef vector <pii> vpii;
- const int maxn = 1010;
- int n, m;
- int x[2][3];
- int y[2][3];
- int color[maxn][maxn];
- int dx[3][8] = {{1, 1, -1, -1, 1, -1, 0, 0}, {1, -1, 0, 0, 0, 0, 0, 0}, {1, 1, -1, -1, 0, 0, 0, 0}};
- int dy[3][8] = {{1, -1, 1, -1, 0, 0, 1, -1}, {0, 0, 1, -1, 0, 0, 0, 0}, {1, -1, 1, -1, 0, 0, 0, 0}};
- int sz[3] = {8, 4, 4};
- inline bool check_inside(int x, int y)
- {
- return x >= 1 && x <= n && y >= 1 && y <= m;
- }
- inline bool is_check(int type, int x0, int y0, int x1, int y1)
- {
- assert(type >= 0 && type <= 2);
- if (!type)
- return abs(x0 - x1) <= 1 && abs(y0 - y1) <= 1;
- if (type == 1)
- return !((x0 - x1) * (y0 - y1));
- return abs(x0 - x1) == abs(y0 - y1);
- }
- inline bool is_check()
- {
- int X = x[0][0];
- int Y = y[0][0];
- return (color[x[1][0]][y[1][0]] == 2 && is_check(0, x[1][0], y[1][0], X, Y)) ||
- (color[x[1][1]][y[1][1]] == 2 && is_check(1, x[1][1], y[1][1], X, Y)) ||
- (color[x[1][2]][y[1][2]] == 2 && is_check(2, x[1][2], y[1][2], X, Y));
- }
- int main()
- {
- freopen(TASKNAME".in", "r", stdin);
- freopen(TASKNAME".out", "w", stdout);
- scanf("%d%d", &n, &m);
- for (int i = 0; i < 2; i++)
- for (int j = 0; j < 3; j++)
- scanf("%d%d", &x[i][j], &y[i][j]), color[x[i][j]][y[i][j]] = i + 1;
- for (int type = 0; type < 3; type++)
- for (int it = 0; it < sz[type]; it++)
- {
- int lx = x[0][type], ly = y[0][type];
- int nx = lx + dx[type][it], ny = ly + dy[type][it];
- if (!check_inside(nx, ny) || color[nx][ny] == 1)
- continue;
- x[0][type] = nx;
- y[0][type] = ny;
- int lcr = color[nx][ny];
- color[nx][ny] = 1;
- color[lx][ly] = 0;
- if (!is_check())
- {
- printf("%d %d %d %d\n", lx, ly, nx, ny);
- printf("%d %d %d %d\n", nx, ny, lx, ly);
- return 0;
- }
- x[0][type] = lx;
- y[0][type] = ly;
- color[nx][ny] = lcr;
- color[lx][ly] = 1;
- }
- printf("-1\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement