Submission #226263

#TimeUsernameProblemLanguageResultExecution timeMemory
226263dolphingarlicDragon 2 (JOI17_dragon2)C++14
100 / 100
2563 ms3092 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...