-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10252.cpp
More file actions
41 lines (39 loc) · 710 Bytes
/
10252.cpp
File metadata and controls
41 lines (39 loc) · 710 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <iostream>
#include <stack>
using namespace std;
void solve() {
int m, n; cin >> m >> n;
stack<int> I, J;
cout << 1 << "\n";
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
if (i == 0) {
cout << "(" << i << "," << j << ")" << "\n";
}
else {
if (j == 0) {
I.push(i); J.push(j);
}
else {
if (i % 2 == 0) {
cout << "(" << i << "," << j << ")" << "\n";
}
else {
cout << "(" << i << "," << n - j << ")" << "\n";
}
}
}
}
}
while (!I.empty() && !J.empty()) {
cout << "(" << I.top() << "," << J.top() <<")" << "\n";
I.pop(); J.pop();
}
}
int main() {
int T; cin >> T;
while (T--) {
solve();
}
return 0;
}