forked from AnkushNaskar/Game-of-Cops-and-Robbers-on-Graphs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrid.cpp
37 lines (30 loc) · 814 Bytes
/
grid.cpp
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
30
31
32
33
34
35
36
37
#include <iostream>
#include <vector>
using namespace std;
void chaseInd(vector<pair<int, int>>& c, pair<int, int> r, int i);
void grid(vector<pair<int, int>> &c, pair <int, int> r, int copCnt) {
if (abs(c[0].second - r.second) == abs(c[0].first - r.first) && abs(c[1].second - r.second) == abs(c[1].first - r.first)) {
if (abs(c[0].first - r.first) == 1 && abs(c[1].first - r.first) == 1) {
if (abs(c[0].first - c[1].first) == 2) {
if (c[0].second < r.second) {
c[0].second++;
}
else {
c[0].second--;
}
}
else if (abs(c[0].second - c[1].second) == 2) {
if (c[0].first < r.first) {
c[0].first++;
}
else {
c[0].first--;
}
}
return;
}
}
for (int i = 0; i < copCnt; i++) {
chaseInd(c, r, i);
}
}