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 <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;
}
# | 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... |