#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
int n,m,l,r,curr;
vector<vector<int>> ans;
signed main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> m;
l = m;
r = m+n-1;
for(int j=30;j>=0;j--){
if(n&(1<<j)){
if(l&(1<<j)){
for(int i=r;i>r-(1<<j);i--){
ans.push_back({i%(1<<j)+curr,i});
}
r -= (1<<j);
}
else{
for(int i=l;i<l+(1<<j);i++){
ans.push_back({i%(1<<j)+curr,i});
}
l += (1<<j);
}
curr += (1<<j);
}
}
for(vector<int> i:ans){
cout << i[0] << " " << i[1] << "\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
55 ms |
18172 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
324 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
56 ms |
18152 KB |
Output is correct |
7 |
Correct |
26 ms |
8824 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
55 ms |
18172 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
324 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
56 ms |
18152 KB |
Output is correct |
11 |
Correct |
26 ms |
8824 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |