-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy path255.cpp.incomplete
More file actions
29 lines (25 loc) · 818 Bytes
/
255.cpp.incomplete
File metadata and controls
29 lines (25 loc) · 818 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <iostream>
using namespace std;
int k, q, m;
bool isMoveAllowed(int thresh) {
int qrow = q / 8, qcol = q % 8;
int mrow = m / 8, mcol = m % 8;
int krow = k / 8, kcol = k % 8;
if (qrow == mrow and qrow == krow) {
if (qcol < mcol and mcol < kcol - thresh) return true;
if (qcol > mcol and mcol > kcol + thresh) return true;
} else if (qcol == mcol and qcol == kcol) {
if (qrow < mrow and qrow < krow - thresh) return true;
if (qrow > mrow and mrow > krow + thresh) return true;
}
return false;
}
int main() {
while (cin >> k >> q >> m) {
if (k == q) cout << "Illegal state" << endl;
else if (not isMoveAllowed(0)) cout << "Illegal move" << endl;
else if (not isMoveAllowed(1)) cout << "Move not allowed" << endl;
else cout << "idk" << endl;
}
return 0;
}