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>
#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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |