# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
600515 | penguinhacker | Sob (COCI19_sob) | C++17 | 88 ms | 9700 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 ll long long
#define ar array
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n, m;
cin >> n >> m;
vector<int> v(n);
iota(v.begin(), v.end(), m);
int offset=0;
while(__builtin_popcount(n)>1) {
int high=31-__builtin_clz(n);
vector<ar<int, 2>> p;
vector<bool> vis(1<<high);
vector<int> mp(1<<high, -1);
for (int i : v) {
int mask=i&((1<<high+1)-1);
if (mask<(1<<high)) {
cout << mask+offset << " " << i << "\n";
vis[mask]=1;
} else
mp[mask-(1<<high)]=i;
}
v.clear();
for (int i=0; i<1<<high; ++i) {
if (!vis[i]) {
assert(mp[i]!=-1);
cout << i+offset << " " << mp[i] << "\n";
} else if (mp[i]!=-1)
v.push_back(mp[i]);
}
n-=1<<high;
offset+=1<<high;
}
for (int i : v)
cout << (i&n-1)+offset << " " << i << "\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... |