Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <iostream>
- #include <iomanip>
- #include <cmath>
- #include <vector>
- #include <set>
- using namespace std;
- //#define int long long
- #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
- const long long INF = 1e18 + 7;
- const double EPS = 1e-9;
- const int N = 1e5 + 10;
- const int MOD = 1e9 + 7;
- bool Rook(int x1, int y1, int x2, int y2) { // figure, target
- return x1 == x2 || y1 == y2;
- }
- bool Elephant(int x1, int y1, int x2, int y2) { // figure, target
- return abs(x1 - x2) == abs(y1 - y2);
- }
- bool Horse(int x1, int y1, int x2, int y2) { // figure, target
- return abs(x1 - x2) + abs(y1 - y2) == 3 && abs(x1 - x2) && abs(y1 - y2);
- }
- bool IsGood(int x, int y, int x1, int y1, int x2, int y2) {
- if (x == x1 && y == y1 || x == x2 && y == y2) {
- return false;
- }
- if (Rook(x1, y1, x2, y2) || Elephant(x2, y2, x1, y1)) {
- return false;
- }
- if (Rook(x1, y1, x, y) && Elephant(x2, y2, x, y) && !Horse(x, y, x1, y1) && !Horse(x, y, x2, y2)) {
- return true;
- }
- }
- void solve() {
- int x, y;
- char c;
- cin >> c >> y;
- x = (int)(c - 'a');
- --y;
- for (int x1 = 0; x1 < 8; ++x1) { // rook
- for (int y1 = 0; y1 < 8; ++y1) {
- for (int x2 = 0; x2 < 8; ++x2) { // elephant
- for (int y2 = 0; y2 < 8; ++y2) {
- if (IsGood(x, y, x1, y1, x2, y2)) {
- cout << char(x1 + 'a') << y1 + 1 << '\n';
- cout << char(x2 + 'a') << y2 + 1 << '\n';
- return;
- }
- }
- }
- }
- }
- }
- int32_t main() {
- IOS;
- int tt = 1;
- while (tt--) {
- solve();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment