#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
const int N = 3007;
struct Point {
int x, y, c;
Point operator - (Point p) {
return {x - p.x, y - p.y};
}
int operator *(Point p) {
return x * p.y - y * p.x;
}
} a[N];
int sign(int x) {
if (x < 0)
return -1;
else if (x == 0)
return 0;
else
return 1;
}
int ans[N][N];
signed main() {
#ifdef HOME
freopen("input.txt", "r", stdin);
#else
#define endl '\n'
ios_base::sync_with_stdio(0); cin.tie(0);
#endif
int n, m;
cin >> n >> m;
for (int i = 1; i <= n; ++i) {
cin >> a[i].x >> a[i].y >> a[i].c;
}
Point A, B;
cin >> A.x >> A.y;
cin >> B.x >> B.y;
for (int i = 1; i <= n; ++i) {
auto l = A - a[i];
auto r = B - a[i];
for (int j = 1; j <= n; ++j) {
if (a[i].c == a[j].c)
continue;
auto v = a[j] - a[i];
if (sign(l * r) * sign(l * v) > 0 && sign(l * r) * sign(v * r) > 0) {
++ans[a[i].c][a[j].c];
}
}
}
int q;
cin >> q;
while (q--) {
int c1, c2;
cin >> c1 >> c2;
cout << ans[c1][c2] << endl;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
81 ms |
512 KB |
Output is correct |
2 |
Correct |
80 ms |
512 KB |
Output is correct |
3 |
Correct |
78 ms |
1016 KB |
Output is correct |
4 |
Correct |
104 ms |
12664 KB |
Output is correct |
5 |
Correct |
139 ms |
49212 KB |
Output is correct |
6 |
Correct |
34 ms |
2424 KB |
Output is correct |
7 |
Correct |
42 ms |
2424 KB |
Output is correct |
8 |
Correct |
34 ms |
512 KB |
Output is correct |
9 |
Correct |
23 ms |
384 KB |
Output is correct |
10 |
Correct |
30 ms |
512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
9 ms |
896 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
81 ms |
512 KB |
Output is correct |
2 |
Correct |
80 ms |
512 KB |
Output is correct |
3 |
Correct |
78 ms |
1016 KB |
Output is correct |
4 |
Correct |
104 ms |
12664 KB |
Output is correct |
5 |
Correct |
139 ms |
49212 KB |
Output is correct |
6 |
Correct |
34 ms |
2424 KB |
Output is correct |
7 |
Correct |
42 ms |
2424 KB |
Output is correct |
8 |
Correct |
34 ms |
512 KB |
Output is correct |
9 |
Correct |
23 ms |
384 KB |
Output is correct |
10 |
Correct |
30 ms |
512 KB |
Output is correct |
11 |
Runtime error |
9 ms |
896 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
12 |
Halted |
0 ms |
0 KB |
- |