-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1904A.cpp
More file actions
39 lines (31 loc) · 803 Bytes
/
1904A.cpp
File metadata and controls
39 lines (31 loc) · 803 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
30
31
32
33
34
35
36
37
38
#include <bits/stdc++.h>
using namespace std;
int dx[4] = {-1, 1, -1, 1}, dy[4] = {-1, -1, 1, 1};
int main()
{
int t;
cin >> t;
while (t--)
{
long long a, b;
cin >> a >> b;
long long x_king, y_king;
cin >> x_king >> y_king;
long long x_queen, y_queen;
cin >> x_queen >> y_queen;
set<pair<int, int>> king_hits, queen_hits;
for (int j = 0; j < 4; j++)
{
king_hits.insert({x_king + dx[j] * a, y_king + dy[j] * b});
king_hits.insert({x_king + dx[j] * b, y_king + dy[j] * a});
queen_hits.insert({x_queen + dx[j] * a, y_queen + dy[j] * b});
queen_hits.insert({x_queen + dx[j] * b, y_queen + dy[j] * a});
}
int ans = 0;
for (auto position : king_hits)
if (queen_hits.find(position) != queen_hits.end())
ans++;
cout << ans << endl;
}
return 0;
}