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;
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_t[30001];
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m, q, x, y;
	cin >> n >> m;
	while (n--) {
		cin >> A.x >> A.y >> q;
		by_t[q].push_back(A);
	}
	cin >> A.x >> A.y >> B.x >> B.y;
	cin >> q;
	while (q--) {
		cin >> 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));
		}
		cout << m << '\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... |