Submission #489649

#TimeUsernameProblemLanguageResultExecution timeMemory
489649rainboySvjetlost (COI18_svjetlost)C11
Compilation error
0 ms0 KiB
#include <math.h> #include <stdio.h> #define N 100000 double hypot(double x, double y) { return sqrt(x * x + y * y); } double max(double a, double b) { return a > b ? a : b; } int xx[N], yy[N], n; char dead[N]; long long cross(int x1, int y1, int x2, int y2) { return (long long) x1 * y2 - (long long) x2 * y1; } long long dot(int x1, int y1, int x2, int y2) { return (long long) x1 * x2 + (long long) y1 * y2; } int check(int x1, int y1, int x2, int y2) { long long c = cross(x1, y1, x2, y2); return c != 0 ? c > 0 : dot(x1, y1, x2, y2) > 0; } double solve() { static int ii[N]; int h, h_, i, cnt; double d, d_; cnt = 0; for (i = 0; i < n; i++) if (!dead[i]) ii[cnt++] = i; d = 0, d_ = 0; for (h = 0, h_ = 0; h < cnt; h++) { while (check(xx[ii[(h + 1) % cnt]] - xx[ii[h]], yy[ii[(h + 1) % cnt]] - yy[ii[h]], xx[ii[(h_ + 1) % cnt]] - xx[ii[h_]], yy[ii[(h_ + 1) % cnt]] - yy[ii[h_]])) { d += hypot(xx[ii[(h_ + 1) % cnt]] - xx[ii[h_]], yy[ii[(h_ + 1) % cnt]] - yy[ii[h_]]); h_ = (h_ + 1) % cnt; } d_ = max(d_, d); d -= hypot(xx[ii[(h + 1) % cnt]] - xx[ii[h]], yy[ii[(h + 1) % cnt]] - yy[ii[h]]); } return d_; } int main() { int q, i; scanf("%d", &n); for (i = 0; i < n; i++) scanf("%d%d", &xx[i], &yy[i]); scanf("%d", &q); printf("%f\n", solve()); while (q--) { int i; scanf("%d", &i), i--; dead[i] = 1; printf("%f\n", solve()); } return 0; }

Compilation message (stderr)

svjetlost.c: In function 'main':
svjetlost.c:50:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   50 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
svjetlost.c:52:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |   scanf("%d%d", &xx[i], &yy[i]);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
svjetlost.c:53:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   53 |  scanf("%d", &q);
      |  ^~~~~~~~~~~~~~~
svjetlost.c:58:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   58 |   scanf("%d", &i), i--;
      |   ^~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccmYxMXD.o: in function `solve':
svjetlost.c:(.text+0x314): undefined reference to `sqrt'
/usr/bin/ld: svjetlost.c:(.text+0x377): undefined reference to `sqrt'
/usr/bin/ld: /tmp/ccmYxMXD.o: in function `hypot':
svjetlost.c:(.text+0x20): undefined reference to `sqrt'
collect2: error: ld returned 1 exit status