#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
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);
| ^~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
52 ms |
5784 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Integer parameter [name=y] equals to 4096, violates the range [4815, 8191] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Integer parameter [name=y] equals to 176, violates the range [178, 189] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
52 ms |
5784 KB |
Output is correct |
5 |
Incorrect |
1 ms |
332 KB |
Integer parameter [name=y] equals to 4096, violates the range [4815, 8191] |
6 |
Halted |
0 ms |
0 KB |
- |