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 1000000
void solve(int *aa, int *bb, int l, int r) {
int n = r - l, m = n / 2, i;
if (n == 1)
aa[0] = 0, bb[0] = l;
else if (n % 2 == 0 && l % 2 == 0) {
solve(aa, bb, l / 2, l / 2 + m), solve(aa + m, bb + m, l / 2, l / 2 + m);
for (i = 0; i < n; i++)
aa[i] <<= 1, bb[i] <<= 1;
for (i = 0; i < m; i++)
aa[m + i] |= 1, bb[m + i] |= 1;
} else if (n % 2 == 0 && l % 2 == 1) {
solve(aa, bb, l / 2, l / 2 + m), solve(aa + m, bb + m, l / 2 + 1, l / 2 + 1 + m);
for (i = 0; i < n; i++)
aa[i] <<= 1, bb[i] <<= 1;
for (i = 0; i < m; i++)
aa[i] |= 1, bb[i] |= 1;
} else if (n % 2 == 1 && l % 2 == 0) {
solve(aa, bb, l / 2, l / 2 + m + 1), solve(aa + m + 1, bb + m + 1, l / 2, l / 2 + m);
for (i = 0; i < n; i++)
aa[i] <<= 1, bb[i] <<= 1;
for (i = 0; i < m; i++)
aa[m + 1 + i] |= 1, bb[m + 1 + i] |= 1;
} else {
solve(aa, bb, l / 2, l / 2 + m + 1), solve(aa + m + 1, bb + m + 1, l / 2 + 1, l / 2 + m + 1);
for (i = 0; i < n; i++)
aa[i] <<= 1, bb[i] <<= 1;
for (i = 0; i < m; i++)
aa[m + 1 + i] |= 1, bb[m + 1 + i] |= 1;
for (i = 0; i < m + 1; i++)
if (aa[i] == l - 1) {
bb[i] |= 1;
break;
}
}
}
int main() {
static int aa[N], bb[N];
int n, m, i;
scanf("%d%d", &n, &m);
solve(aa, bb, m, m + n);
for (i = 0; i < n; i++)
printf("%d %d\n", aa[i], bb[i]);
return 0;
}
Compilation message (stderr)
sob.c: In function 'main':
sob.c:46:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
46 | scanf("%d%d", &n, &m);
| ^~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |