Submission #486431

#TimeUsernameProblemLanguageResultExecution timeMemory
486431rainboyRelay (COI16_relay)C11
0 / 100
2 ms204 KiB
#include <stdio.h> #define N 100000 #define M 100000 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 xx[N + M], yy[N + M], xxl[N], yyl[N], xxr[N], yyr[N]; int visible(int i1, int i2) { return cross2(xxr[i1], yyr[i1], xxl[i2], yyl[i2]) <= 0 || cross2(xxr[i2], yyr[i2], xxl[i1], yyl[i1]) <= 0; } int main() { static char good[N]; int n, m, i, i1, i2, j, p, q, 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 = 0; i1 < n; i1++) { for (j = 0; j < m; j++) { p = (j - 1 + m) % m, q = (j + 1) % m; if (cross(xx[i1], yy[i1], xx[n + p], yy[n + p], xx[n + j], yy[n + j]) >= 0 && cross(xx[i1], yy[i1], xx[n + q], yy[n + q], xx[n + j], yy[n + j]) > 0) xxl[i1] = xx[i1] - xx[n + j], yyl[i1] = yy[i1] - yy[n + j]; if (cross(xx[i1], yy[i1], xx[n + q], yy[n + q], xx[n + j], yy[n + j]) <= 0 && cross(xx[i1], yy[i1], xx[n + p], yy[n + p], xx[n + j], yy[n + j]) < 0) xxr[i1] = xx[n + j] - xx[i1], yyr[i1] = yy[n + j] - yy[i1]; } } for (i1 = 1; i1 < n; i1++) if (visible(0, i1)) { good[i1] = 1; for (i2 = 1; i2 < n; i2++) if (visible(i1, i2)) 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:24:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
relay.c:26:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |   scanf("%d%d", &xx[i], &yy[i]);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
relay.c:27:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |  scanf("%d", &m);
      |  ^~~~~~~~~~~~~~~
relay.c:29:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |   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...