#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
typedef long long ll;
using namespace std;
struct Point {
ll x, y;
} A, B;
inline bool ccw(Point X, Point Y, Point Z) {
return (X.x - Y.x) * (Z.y - Y.y) <= (X.y - Y.y) * (Z.x - Y.x);
}
vector<Point> by_tribe[30000];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, m;
cin >> n >> m;
FOR(i, 0, n) {
Point p;
int tribe;
cin >> p.x >> p.y >> tribe;
by_tribe[tribe - 1].push_back(p);
}
cin >> A.x >> A.y >> B.x >> B.y;
int q;
cin >> q;
while (q--) {
int x, y;
cin >> x >> y;
int ans = 0;
for (Point i : by_tribe[x - 1]) for (Point j : by_tribe[y - 1]) {
if (ccw(i, A, B)) ans += (ccw(i, A, j) && ccw(j, B, i));
else ans += (ccw(j, A, i) && ccw(i, B, j));
}
cout << ans << '\n';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
1152 KB |
Output is correct |
2 |
Correct |
22 ms |
1152 KB |
Output is correct |
3 |
Correct |
29 ms |
1152 KB |
Output is correct |
4 |
Correct |
40 ms |
2168 KB |
Output is correct |
5 |
Correct |
35 ms |
2304 KB |
Output is correct |
6 |
Correct |
7 ms |
1280 KB |
Output is correct |
7 |
Correct |
7 ms |
1280 KB |
Output is correct |
8 |
Correct |
11 ms |
1152 KB |
Output is correct |
9 |
Correct |
10 ms |
1152 KB |
Output is correct |
10 |
Correct |
12 ms |
1152 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1002 ms |
2372 KB |
Output is correct |
2 |
Correct |
1766 ms |
2432 KB |
Output is correct |
3 |
Correct |
54 ms |
2560 KB |
Output is correct |
4 |
Correct |
18 ms |
2560 KB |
Output is correct |
5 |
Correct |
23 ms |
2560 KB |
Output is correct |
6 |
Correct |
1012 ms |
2676 KB |
Output is correct |
7 |
Correct |
975 ms |
2548 KB |
Output is correct |
8 |
Correct |
493 ms |
2428 KB |
Output is correct |
9 |
Correct |
469 ms |
2176 KB |
Output is correct |
10 |
Correct |
490 ms |
2300 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
1152 KB |
Output is correct |
2 |
Correct |
22 ms |
1152 KB |
Output is correct |
3 |
Correct |
29 ms |
1152 KB |
Output is correct |
4 |
Correct |
40 ms |
2168 KB |
Output is correct |
5 |
Correct |
35 ms |
2304 KB |
Output is correct |
6 |
Correct |
7 ms |
1280 KB |
Output is correct |
7 |
Correct |
7 ms |
1280 KB |
Output is correct |
8 |
Correct |
11 ms |
1152 KB |
Output is correct |
9 |
Correct |
10 ms |
1152 KB |
Output is correct |
10 |
Correct |
12 ms |
1152 KB |
Output is correct |
11 |
Correct |
1002 ms |
2372 KB |
Output is correct |
12 |
Correct |
1766 ms |
2432 KB |
Output is correct |
13 |
Correct |
54 ms |
2560 KB |
Output is correct |
14 |
Correct |
18 ms |
2560 KB |
Output is correct |
15 |
Correct |
23 ms |
2560 KB |
Output is correct |
16 |
Correct |
1012 ms |
2676 KB |
Output is correct |
17 |
Correct |
975 ms |
2548 KB |
Output is correct |
18 |
Correct |
493 ms |
2428 KB |
Output is correct |
19 |
Correct |
469 ms |
2176 KB |
Output is correct |
20 |
Correct |
490 ms |
2300 KB |
Output is correct |
21 |
Correct |
1006 ms |
2548 KB |
Output is correct |
22 |
Correct |
1759 ms |
2432 KB |
Output is correct |
23 |
Correct |
1870 ms |
2688 KB |
Output is correct |
24 |
Correct |
580 ms |
3868 KB |
Output is correct |
25 |
Correct |
55 ms |
3832 KB |
Output is correct |
26 |
Correct |
60 ms |
3960 KB |
Output is correct |
27 |
Correct |
25 ms |
2936 KB |
Output is correct |
28 |
Correct |
24 ms |
2944 KB |
Output is correct |
29 |
Correct |
2614 ms |
4000 KB |
Output is correct |
30 |
Correct |
78 ms |
3572 KB |
Output is correct |
31 |
Correct |
62 ms |
3704 KB |
Output is correct |
32 |
Correct |
66 ms |
3704 KB |
Output is correct |
33 |
Correct |
521 ms |
3832 KB |
Output is correct |
34 |
Correct |
50 ms |
3960 KB |
Output is correct |
35 |
Correct |
50 ms |
3704 KB |
Output is correct |
36 |
Correct |
56 ms |
3704 KB |
Output is correct |
37 |
Correct |
58 ms |
3960 KB |
Output is correct |
38 |
Correct |
870 ms |
4088 KB |
Output is correct |
39 |
Correct |
693 ms |
3832 KB |
Output is correct |
40 |
Correct |
586 ms |
3832 KB |
Output is correct |
41 |
Correct |
2295 ms |
3676 KB |
Output is correct |
42 |
Correct |
1507 ms |
3560 KB |
Output is correct |
43 |
Correct |
1154 ms |
3704 KB |
Output is correct |
44 |
Correct |
1537 ms |
2676 KB |
Output is correct |
45 |
Correct |
742 ms |
2632 KB |
Output is correct |
46 |
Correct |
470 ms |
2688 KB |
Output is correct |
47 |
Correct |
1120 ms |
2796 KB |
Output is correct |
48 |
Correct |
680 ms |
2680 KB |
Output is correct |
49 |
Correct |
405 ms |
2828 KB |
Output is correct |