#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define MP make_pair
#define PB push_back
using ll = long long;
using ld = long double;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
template<typename T>
using vec = vector<T>;
template<typename T, int N>
using arr = array<T, N>;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
const int INF = 1e9 + 7;
const int MOD = 998244353;
vec<int> ans;
void solve(int N, int M)
{
if (N == 0) return;
int mod = __lg(N - 1) + 1;
int s = M / (1 << mod) * (1 << mod) + N - 1;
for (int i = s; i >= M; i--)
ans[N - (s - i) - 1] = i;
solve(N - (s - M + 1), s + 1);
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int N, M;
cin >> N >> M;
ans.resize(N);
solve(N, M);
for (int i = 0; i < N; i++)
cout << i << ' ' << ans[i] << '\n';
}
# | 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... |