# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
202652 | SorahISA | Sob (COCI19_sob) | C++14 | 56 ms | 12396 KiB |
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
#define double long double
#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
const int maxn = 1 << 20;
vector<int> v(maxn);
int32_t main() {
fastIO();
int n, m, tok = 0;
cin >> n >> m;
/// for subtask 1 : n == 2^k ///
if ((1 << __lg(n)) == n) {
for (int i = m+n-1; i >= m; --i) {
if (((n-1) & i) == (n-1)) {tok = i+1-n; break;}
}
for (int i = 0; i < n; ++i) {
cout << i << " " << (tok+i < m ? tok+i+n : tok+i) << "\n";
}
return 0;
}
/// for subtask 2 : n+m == 2^k ///
int now = 1, p;
for (int i = 1; i < n; ++i) {
now = (now ? now - 1 : i - 1);
p = now;
while (v[now]) {
swap(v[now], v[p]);
p += (1 << (int)__lg(v[now]) + 1);
}
v[now] = i;
}
vector<pair<int, int>> ans;
for (int i = 0; i < n; ++i) ans.push_back({v[i], n+m-i-1});
sort(ans.begin(), ans.end());
for (auto [L, R] : ans) cout << L << " " << R << "\n";
return 0;
}
Compilation message (stderr)
# | 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... |