#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 1e6 + 5;
int n, m;
bool ok[MAXN];
int res[MAXN];
map< int, int> mp;
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin >> n >> m;
for(int x = 20; x >= 0; x --){
int mask = (1 << x) - 1;
mp.clear();
for(int i = m; i < n + m; i ++){
if( !ok[i] )
mp[mask & i] = i;
}
for(int i = 0; i < n; i ++){
if( !ok[i] && mp[i & mask]){
res[i] = mp[i & mask];
ok[res[i]] = true, ok[i] = true;
mp[mask & i] = 0;
}
}
}
for(int i = 0; i < n; i ++)
cout << i << " " << res[i] << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
430 ms |
29980 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
588 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
2 ms |
332 KB |
Output is correct |
6 |
Correct |
430 ms |
29984 KB |
Output is correct |
7 |
Correct |
253 ms |
14504 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
332 KB |
Output is correct |
7 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
430 ms |
29980 KB |
Output is correct |
5 |
Correct |
9 ms |
588 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
2 ms |
332 KB |
Output is correct |
10 |
Correct |
430 ms |
29984 KB |
Output is correct |
11 |
Correct |
253 ms |
14504 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
2 ms |
332 KB |
Output is correct |
18 |
Correct |
2 ms |
332 KB |
Output is correct |
19 |
Correct |
103 ms |
6472 KB |
Output is correct |
20 |
Correct |
361 ms |
22652 KB |
Output is correct |
21 |
Correct |
16 ms |
1032 KB |
Output is correct |
22 |
Correct |
8 ms |
672 KB |
Output is correct |
23 |
Correct |
484 ms |
32236 KB |
Output is correct |
24 |
Correct |
687 ms |
57136 KB |
Output is correct |
25 |
Correct |
629 ms |
56264 KB |
Output is correct |