이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define f first
#define s second
const int N = 3e4 + 69;
struct point {
int x, y;
};
point a[N];
point s, e;
int n, m, d1, e1, d2, e2, q, c[N];
vector<point> g[N];
int cross(point a, point b, point c) {
point v = {b.x - a.x, b.y - a.y};
point v1 = {c.x - a.x, c.y - a.y};
int r = v1.x * v.y - v1.y * v.x;
assert(r != 0);
if (r > 0)
return 1; //desno
return -1; //levo
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int tt = 1;
//cin >> tt;
while (tt--) {
cin >> n >> m;
for (int i = 1;i <= n;i++) {
cin >> a[i].x >> a[i].y >> c[i];
g[c[i]].push_back(a[i]);
}
cin >> s.x >> s.y >> e.x >> e.y;
cin >> q;
while (q--) {
int a, b;
cin >> a >> b;
int ans = 0;
for (auto u : g[a]) {
for (auto t : g[b]) {
//ili je u trouglu
//ili se seku duzi
if (cross(u, s, t) == cross(s, e, t) && cross(s, e, t) == cross(e, u, t))
++ans;
else if (cross(u, t, s) != cross(u, t, e) && cross(s, e, u) != cross(s, e, t))
++ans;
}
}
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... |