#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 mask=0;
ll temp=n-1;
while (temp>0){
temp>>=1;
mask++;
}
ll bitmask = 1LL << (mask) ;
bitmask--;
for (ll i = m + n - 1; i >= m; i--) {
if ((i & (n - 1)) == (n - 1) && (((i | (n - 1))& bitmask) == (i & (n - 1)))) {
start = i;
break;
}
}
ll nn = n-1;
for (ll i = start; i >= m; i--) {
cout << nn << " " << i << endl;
nn--;
}
for (ll i = nn; i >= 0; i--) {
cout << i << " " << start+1+ (nn - 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... |