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;
void solve() {
int n, m;
cin >> n >> m;
list<int> l;
for (int i = m; i < m + n; ++i) {
l.push_back(i);
}
auto it = l.begin();
for (int i = n - 1; i >= 0; --i) {
auto tit = it;
while ((i & *it) != i && it != l.begin()) {
--it;
}
if ((i & *it) == i) {
cout << i << ' ' << *it << '\n';
it = l.erase(it);
if (it == l.end()) --it;
continue;
}
it = tit;
while ((i & *it) != i && next(it) != l.end()) {
++it;
}
cout << i << ' ' << *it << '\n';
it = l.erase(it);
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
solve();
return 0;
}
# | 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... |