This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <stdio.h>
#define N 100000
#define MD 365
int max(int a, int b) { return a > b ? a : b; }
unsigned int X = 12345;
int rand_() {
return (X *= 3) >> 1;
}
int dd[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
int idx(int m, int d) {
int h;
for (h = 0; h < m; h++)
d += dd[h];
return d;
}
int ll[N], rr[N];
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 (ll[ii[j]] == ll[i_])
j++;
else if (ll[ii[j]] < ll[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];
int n, l_, r_, i, r, r1, k;
scanf("%d", &n), l_ = idx(2, 0), r_ = idx(10, 29);
for (i = 0; i < n; i++) {
int ml, dl, mr, dr;
scanf("%d%d%d%d", &ml, &dl, &mr, &dr), ml--, dl--, mr--, dr--;
ll[i] = idx(ml, dl), rr[i] = idx(mr, dr);
}
for (i = 0; i < n; i++)
ii[i] = i;
sort(ii, 0, n);
r = l_, k = 0, i = 0;
while (r <= r_) {
r1 = r;
while (i < n && ll[ii[i]] <= r)
r1 = max(r1, rr[ii[i++]]);
if (r == r1) {
printf("0\n");
return 0;
}
r = r1, k++;
}
printf("%d\n", k);
return 0;
}
Compilation message (stderr)
flower.c: In function 'main':
flower.c:49:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
49 | scanf("%d", &n), l_ = idx(2, 0), r_ = idx(10, 29);
| ^~~~~~~~~~~~~~~
flower.c:53:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
53 | scanf("%d%d%d%d", &ml, &dl, &mr, &dr), ml--, dl--, mr--, dr--;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |