Submission #795888

#TimeUsernameProblemLanguageResultExecution timeMemory
795888rainboy덩치 (KOI13_body)C11
18 / 18
1 ms340 KiB
#include <stdio.h> #define N 50 unsigned int X = 12345; int rand_() { return (X *= 3) >> 1; } int xx[N], yy[N]; int compare_y(int i, int j) { return yy[i] - yy[j]; } int compare_x(int i, int j) { return xx[i] != xx[j] ? xx[j] - xx[i] : yy[i] - yy[j]; } int (*compare)(int, int); 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) { int c = compare(ii[j], i_); if (c == 0) j++; else if (c < 0) { 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 ft[N]; void update(int i, int n) { while (i < n) { ft[i]++; i |= i + 1; } } int query(int i) { int x = 0; while (i >= 0) { x += ft[i]; i &= i + 1, i--; } return x; } int main() { static int ii[N], rr[N]; int n, h, i, y; scanf("%d", &n); for (i = 0; i < n; i++) scanf("%d%d", &xx[i], &yy[i]); for (i = 0; i < n; i++) ii[i] = i; compare = compare_y, sort(ii, 0, n); for (h = 0, y = 0; h < n; h++) yy[ii[h]] = h + 1 == n || yy[ii[h + 1]] != yy[ii[h]] ? y++ : y; compare = compare_x, sort(ii, 0, n); for (h = 0; h < n; h++) { i = ii[h]; rr[i] = query(n - 2 - yy[i]) + 1; update(n - 1 - yy[i], n); } for (i = 0; i < n; i++) printf("%d ", rr[i]); printf("\n"); return 0; }

Compilation message (stderr)

bb.c: In function 'main':
bb.c:63:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   63 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
bb.c:65:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   65 |   scanf("%d%d", &xx[i], &yy[i]);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...