Submission #811211

#TimeUsernameProblemLanguageResultExecution timeMemory
811211PringSob (COCI19_sob)C++14
10 / 110
292 ms7964 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...