#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
#define MAXN 3005
#define MAXQ 100005
typedef long long lint;
int DX[MAXN], DY[MAXN], TR[MAXN], F[MAXQ], G[MAXQ];
int ans[MAXN][MAXN];
lint ccw(int x1, int y1, int x2, int y2, int x3, int y3) {
return (lint) x1 * y2 + (lint) x2 * y3 + (lint) x3 * y1 - (lint) x2 * y1 - (lint) x3 * y2 - (lint) x1 * y3;
}
int dir(int x1, int y1, int x2, int y2, int x3, int y3) {
return ccw(x1, y1, x2, y2, x3, y3) < 0 ? -1 : 1;
}
int main() {
int N, M, Q;
int HX1, HY1, HX2, HY2;
scanf("%d%d", &N, &M);
for(int i = 0; i < N; i++) scanf("%d%d%d", DX + i, DY + i, TR + i);
scanf("%d%d%d%d", &HX1, &HY1, &HX2, &HY2);
scanf("%d", &Q);
for(int i = 0; i < Q; i++) scanf("%d%d", F + i, G + i);
for(int i = 0; i < N; i++) for(int j = 0; j < N; j++)
if(i != j && dir(DX[i], DY[i], HX1, HY1, HX2, HY2) == dir(DX[i], DY[i], HX1, HY1, DX[j], DY[j]) && dir(DX[i], DY[i], HX2, HY2, HX1, HY1) == dir(DX[i], DY[i], HX2, HY2, DX[j], DY[j])) ans[TR[i]][TR[j]]++;
for(int i = 0; i < Q; i++) printf("%d\n", ans[F[i]][G[i]]);
return 0;
}
Compilation message
dragon2.cpp: In function 'int main()':
dragon2.cpp:27:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &N, &M);
~~~~~^~~~~~~~~~~~~~~~
dragon2.cpp:28:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
for(int i = 0; i < N; i++) scanf("%d%d%d", DX + i, DY + i, TR + i);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dragon2.cpp:29:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d%d%d", &HX1, &HY1, &HX2, &HY2);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dragon2.cpp:30:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &Q);
~~~~~^~~~~~~~~~
dragon2.cpp:31:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
for(int i = 0; i < Q; i++) scanf("%d%d", F + i, G + i);
~~~~~^~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
139 ms |
376 KB |
Output is correct |
2 |
Correct |
130 ms |
376 KB |
Output is correct |
3 |
Correct |
135 ms |
888 KB |
Output is correct |
4 |
Correct |
163 ms |
9464 KB |
Output is correct |
5 |
Correct |
197 ms |
27248 KB |
Output is correct |
6 |
Correct |
80 ms |
2296 KB |
Output is correct |
7 |
Correct |
78 ms |
2296 KB |
Output is correct |
8 |
Correct |
127 ms |
380 KB |
Output is correct |
9 |
Correct |
75 ms |
376 KB |
Output is correct |
10 |
Correct |
76 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4 ms |
632 KB |
Time limit exceeded (wall clock) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
139 ms |
376 KB |
Output is correct |
2 |
Correct |
130 ms |
376 KB |
Output is correct |
3 |
Correct |
135 ms |
888 KB |
Output is correct |
4 |
Correct |
163 ms |
9464 KB |
Output is correct |
5 |
Correct |
197 ms |
27248 KB |
Output is correct |
6 |
Correct |
80 ms |
2296 KB |
Output is correct |
7 |
Correct |
78 ms |
2296 KB |
Output is correct |
8 |
Correct |
127 ms |
380 KB |
Output is correct |
9 |
Correct |
75 ms |
376 KB |
Output is correct |
10 |
Correct |
76 ms |
376 KB |
Output is correct |
11 |
Execution timed out |
4 ms |
632 KB |
Time limit exceeded (wall clock) |
12 |
Halted |
0 ms |
0 KB |
- |