42 lines
786 B
C++
42 lines
786 B
C++
#include <fstream>
|
|
#include <cstdlib>
|
|
|
|
using namespace std;
|
|
|
|
int main() {
|
|
ifstream fin("INPUT.TXT");
|
|
ofstream fout("OUTPUT.TXT");
|
|
|
|
char start[10], end[10];
|
|
fin >> start >> end;
|
|
fin.close();
|
|
|
|
int start_col = start[0] - 'a';
|
|
int start_row = start[1] - '1';
|
|
|
|
int end_col = end[0] - 'a';
|
|
int end_row = end[1] - '1';
|
|
|
|
int can_reach = 0;
|
|
|
|
if (end_row > start_row) {
|
|
int diff_row = end_row - start_row;
|
|
int diff_col = end_col - start_col;
|
|
if (diff_col < 0) diff_col = -diff_col;
|
|
|
|
if (diff_row == diff_col) {
|
|
can_reach = 1;
|
|
}
|
|
}
|
|
|
|
if (can_reach) {
|
|
fout << "YES\n";
|
|
} else {
|
|
fout << "NO\n";
|
|
}
|
|
|
|
fout.close();
|
|
|
|
return 0;
|
|
}
|