Submission #486419

#TimeUsernameProblemLanguageResultExecution timeMemory
486419rainboyRelay (COI16_relay)C11
18 / 100
2078 ms3076 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...