# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
486419 |
2021-11-11T16:01:58 Z |
rainboy |
Relay (COI16_relay) |
C |
|
2000 ms |
3076 KB |
#include <stdio.h>
#define N 100000
#define M 100000
int xx[N + M], n, m;
long long cross2(int x1, int y1, int x2, int y2) {
return (long long) x1 * y2 - (long long) x2 * y1;
}
long long cross(int x0, int y0, int x1, int y1, int x2, int y2) {
return cross2(x1 - x0, y1 - y0, x2 - x0, y2 - y0);
}
int visible(int i1, int i2, int *xx, int *yy) {
int j;
for (j = 0; j < m; j++) {
int p = (j - 1 + m) % m, q = (j + 1) % m;
long long c1pj = cross(xx[i1], yy[i1], xx[n + p], yy[n + p], xx[n + j], yy[n + j]);
long long c1qj = cross(xx[i1], yy[i1], xx[n + q], yy[n + q], xx[n + j], yy[n + j]);
long long c2pj = cross(xx[i2], yy[i2], xx[n + p], yy[n + p], xx[n + j], yy[n + j]);
long long c2qj = cross(xx[i2], yy[i2], xx[n + q], yy[n + q], xx[n + j], yy[n + j]);
long long c1j2 = cross(xx[i1], yy[i1], xx[n + j], yy[n + j], xx[i2], yy[i2]);
if (c1j2 >= 0 && c1qj >= 0 && c2pj <= 0)
return 1;
if (c1j2 <= 0 && c1pj <= 0 && c2qj >= 0)
return 1;
}
return 0;
}
int main() {
static char good[N];
static int xx[N], yy[N];
int i, i1, i2, j, k;
scanf("%d", &n);
for (i = 0; i < n; i++)
scanf("%d%d", &xx[i], &yy[i]);
scanf("%d", &m);
for (j = 0; j < m; j++)
scanf("%d%d", &xx[n + j], &yy[n + j]);
for (i1 = 1; i1 < n; i1++)
if (visible(0, i1, xx, yy)) {
good[i1] = 1;
for (i2 = 1; i2 < n; i2++)
if (visible(i1, i2, xx, yy))
good[i2] = 1;
}
k = 0;
for (i = 1; i < n; i++)
if (good[i])
k++;
printf("%d\n", k);
return 0;
}
Compilation message
relay.c: In function 'main':
relay.c:40:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
40 | scanf("%d", &n);
| ^~~~~~~~~~~~~~~
relay.c:42:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
42 | scanf("%d%d", &xx[i], &yy[i]);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
relay.c:43:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
43 | scanf("%d", &m);
| ^~~~~~~~~~~~~~~
relay.c:45:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
45 | scanf("%d%d", &xx[n + j], &yy[n + j]);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
44 ms |
204 KB |
Output is correct |
2 |
Correct |
45 ms |
204 KB |
Output is correct |
3 |
Correct |
25 ms |
304 KB |
Output is correct |
4 |
Correct |
12 ms |
204 KB |
Output is correct |
5 |
Correct |
27 ms |
304 KB |
Output is correct |
6 |
Correct |
27 ms |
292 KB |
Output is correct |
7 |
Correct |
54 ms |
204 KB |
Output is correct |
8 |
Correct |
27 ms |
204 KB |
Output is correct |
9 |
Correct |
8 ms |
204 KB |
Output is correct |
10 |
Correct |
8 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
44 ms |
204 KB |
Output is correct |
2 |
Correct |
45 ms |
204 KB |
Output is correct |
3 |
Correct |
25 ms |
304 KB |
Output is correct |
4 |
Correct |
12 ms |
204 KB |
Output is correct |
5 |
Correct |
27 ms |
304 KB |
Output is correct |
6 |
Correct |
27 ms |
292 KB |
Output is correct |
7 |
Correct |
54 ms |
204 KB |
Output is correct |
8 |
Correct |
27 ms |
204 KB |
Output is correct |
9 |
Correct |
8 ms |
204 KB |
Output is correct |
10 |
Correct |
8 ms |
204 KB |
Output is correct |
11 |
Execution timed out |
2074 ms |
332 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
44 ms |
204 KB |
Output is correct |
2 |
Correct |
45 ms |
204 KB |
Output is correct |
3 |
Correct |
25 ms |
304 KB |
Output is correct |
4 |
Correct |
12 ms |
204 KB |
Output is correct |
5 |
Correct |
27 ms |
304 KB |
Output is correct |
6 |
Correct |
27 ms |
292 KB |
Output is correct |
7 |
Correct |
54 ms |
204 KB |
Output is correct |
8 |
Correct |
27 ms |
204 KB |
Output is correct |
9 |
Correct |
8 ms |
204 KB |
Output is correct |
10 |
Correct |
8 ms |
204 KB |
Output is correct |
11 |
Execution timed out |
2078 ms |
3076 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
44 ms |
204 KB |
Output is correct |
2 |
Correct |
45 ms |
204 KB |
Output is correct |
3 |
Correct |
25 ms |
304 KB |
Output is correct |
4 |
Correct |
12 ms |
204 KB |
Output is correct |
5 |
Correct |
27 ms |
304 KB |
Output is correct |
6 |
Correct |
27 ms |
292 KB |
Output is correct |
7 |
Correct |
54 ms |
204 KB |
Output is correct |
8 |
Correct |
27 ms |
204 KB |
Output is correct |
9 |
Correct |
8 ms |
204 KB |
Output is correct |
10 |
Correct |
8 ms |
204 KB |
Output is correct |
11 |
Execution timed out |
2074 ms |
332 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |