# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
226265 | dolphingarlic | Dragon 2 (JOI17_dragon2) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
struct Point { ll x, y; } A, B;
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_t[30001];
int main() {
int n, m, q, x, y;
scanf("%d %d", &n, &m);
while (n--) {
scanf("%d %d %d", &A.x, &A.y, &A.q);
by_t[q].push_back(A);
}
scanf("%d %d %d %d %d", &A.x, &A.y, &B.x, &B.y, &q);
while (q--) {
scanf("%d %d", &x, &y);
m = 0;
for (Point i : by_t[x]) for (Point j : by_t[y]) {
if (ccw(i, A, B)) m += (ccw(i, A, j) && ccw(j, B, i));
else m += (ccw(j, A, i) && ccw(i, B, j));
}
printf("%d\n", m);
}
return 0;
}