#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;
const int MXN = 1048580, LG = 20;
int n, m;
int a[MXN], b[MXN];
inline int SORT0(int *a, int l, int r, int lg) {
int L = l, R = r - 1;
while (true) {
while (l <= R && a[R] & lg) R--;
if (l > R) break;
while ((a[L] & lg) == 0) L++;
if (L > R) break;
swap(a[L], a[R]);
}
for (int i = l; i < r; i++) {
if (a[i] & lg) return i;
}
return 0;
}
void SORT(int l, int r, int lg) {
// cout << "SORT " << l << ' ' << r << ' ' << lg << endl;
if (l + 1 >= r) return;
int mid = SORT0(a, l, r, lg);
SORT0(b, l, r, lg);
SORT(l, mid, lg << 1);
SORT(mid, r, lg << 1);
}
void solve() {
cin >> n >> m;
for (int i = 0; i < n; i++) {
a[i] = i;
b[i] = m + i;
}
SORT(0, n, 1);
for (int i = 0; i < n; i++) cout << a[i] << ' ' << b[i] << endl;
}
int32_t main() {
cin.tie(0) -> sync_with_stdio(false);
solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
292 ms |
7964 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
292 ms |
7964 KB |
Output is correct |
5 |
Incorrect |
4 ms |
340 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |