#include "bits/stdc++.h"
#define endl '\n'
#define pb push_back
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<int>::iterator vit;
typedef set<int> si;
typedef map<int, int> mii;
void solve() {
ll n, m;
cin >> n >> m;
ll start = 0;
ll nn = n - 1;
vl ans(n);
ll fin = m;
while (nn >=0) {
ll temp = nn;
ll mask = 0;
while (temp > 0) {
temp >>= 1;
mask++;
}
//ll bitmask = 1LL << (mask);
//bitmask--;
//cout << nn << " " << bitmask;
for (ll i = fin ; i <= m+n+1; i++) {
if (((i&nn)==nn)) {
start = i;
//cout << start << " _ " << nn << endl;
break;
}
}
for (ll i = start; i >= fin; i--) {
ans[nn] = i;
nn--;
}
fin = start+1;
}
for (ll i = 0; i < n; i++) {
cout << i << " " << ans[i] << endl;
}
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
unsigned long long ct = 1;
// cin >> ct;
while (ct--)
solve();
}
# | 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... |