Submission #740608

#TimeUsernameProblemLanguageResultExecution timeMemory
740608rainboyA Game with Grundy (CCO20_day1problem1)C11
25 / 25
79 ms4872 KiB
#include <stdio.h> #define N 100000 long long min(long long a, long long b) { return a < b ? a : b; } long long max(long long a, long long b) { return a > b ? a : b; } unsigned int Z = 12345; int rand_() { return (Z *= 3) >> 1; } int xx[N * 2]; void sort(int *ii, int l, int r) { while (l < r) { int i = l, j = l, k = r, i_ = ii[l + rand_() % (r - l)], tmp; while (j < k) if (xx[ii[j]] == xx[i_]) j++; else if (xx[ii[j]] < xx[i_]) { tmp = ii[i], ii[i] = ii[j], ii[j] = tmp; i++, j++; } else { k--; tmp = ii[j], ii[j] = ii[k], ii[k] = tmp; } sort(ii, l, i); l = k; } } int main() { static int ii[N * 2], kk[N + 1]; int n, l, r, y, i, d; scanf("%d%d%d%d", &n, &l, &r, &y); for (i = 0; i < n; i++) { int x, dx, dy; scanf("%d%d%d", &x, &dy, &dx); xx[i << 1 | 0] = max(l, x - (long long) (y * dx + dy - 1) / dy + 1); xx[i << 1 | 1] = min(r, x + (long long) (y * dx + dy - 1) / dy - 1) + 1; } for (i = 0; i < n * 2; i++) ii[i] = i; sort(ii, 0, n * 2); kk[0] += xx[ii[0]] - l; for (i = 0, d = 0; i + 1 < n * 2; i++) { d += (ii[i] & 1) == 0 ? 1 : -1; kk[d] += xx[ii[i + 1]] - xx[ii[i]]; } kk[0] += r + 1 - xx[ii[n * 2 - 1]]; for (d = 1; d <= n; d++) kk[d] += kk[d - 1]; for (d = 0; d <= n; d++) printf("%d\n", kk[d]); return 0; }

Compilation message (stderr)

Main.c: In function 'main':
Main.c:39:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |  scanf("%d%d%d%d", &n, &l, &r, &y);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.c:43:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |   scanf("%d%d%d", &x, &dy, &dx);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...