#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
vector <pair<int,int>> ans;
void slv(int n, int m, vector <pair<int,int>> v1, vector <pair<int,int>> v2){
if(n==0) return;
if(n==1){
ans.push_back({v1.back().second,v2.back().second});
return;
}
vector <pair<int,int>> a1,a2,b1,b2;
for(auto i: v1){
if(i.first%2==0) a1.push_back({i.first/2,i.second});
else a2.push_back({i.first/2,i.second});
}
if(!(n&1) || !(m&1)){
for(auto i: v2){
if(i.first%2==0) b1.push_back({i.first/2,i.second});
else b2.push_back({i.first/2,i.second});
}
}
else{
b1.push_back({v2[0].first/2,v2[0].second});
for(auto i: v2){
if(i==v2[0]) continue;
if(i.first%2==0) b1.push_back({i.first/2,i.second});
else b2.push_back({i.first/2,i.second});
}
}
slv((int)a1.size(), b1[0].first, a1, b1);
slv((int)a2.size(), b2[0].first, a2, b2);
return;
}
int main()
{
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int n,m;
cin >> n >> m;
vector <pair<int,int>> v1,v2;
for(int i = 0; i < n; i++) v1.push_back({i,i});
for(int i = m; i < n+m; i++) v2.push_back({i,i});
slv(n,m,v1,v2);
for(auto i: ans) cout << i.first << " " << i.second << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
297 ms |
24360 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
588 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
308 KB |
Output is correct |
6 |
Correct |
258 ms |
24408 KB |
Output is correct |
7 |
Correct |
124 ms |
12292 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 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 |
308 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
297 ms |
24360 KB |
Output is correct |
5 |
Correct |
3 ms |
588 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
308 KB |
Output is correct |
10 |
Correct |
258 ms |
24408 KB |
Output is correct |
11 |
Correct |
124 ms |
12292 KB |
Output is correct |
12 |
Correct |
1 ms |
204 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 |
308 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
52 ms |
5644 KB |
Output is correct |
20 |
Correct |
200 ms |
20536 KB |
Output is correct |
21 |
Correct |
7 ms |
1100 KB |
Output is correct |
22 |
Correct |
4 ms |
588 KB |
Output is correct |
23 |
Correct |
306 ms |
31024 KB |
Output is correct |
24 |
Correct |
519 ms |
47916 KB |
Output is correct |
25 |
Correct |
507 ms |
47576 KB |
Output is correct |