-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy path3.cpp
More file actions
73 lines (71 loc) · 1.71 KB
/
3.cpp
File metadata and controls
73 lines (71 loc) · 1.71 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include<bits/stdc++.h>
using namespace std;
int arr[64][2];
int top = -1;
int main(){
int t; cin>>t;
while(t--){
int r,c;
cin>>r>>c;
int x;
if(r != c){
top++;
x = (r+c)/2;
arr[top][0] = x;
arr[top][1] = x;
top++;
arr[top][0] = 1;
arr[top][1] = 1;
}
else{
x = r;
if(x != 1){
top++;
arr[top][0] = 1;
arr[top][1] = 1;
}
}
for(int i=2;i<=8;i++){
top++;
arr[top][0] = i;
arr[top][1] = i;
if(i == 8){
if(x == 8){
cout<<top<<endl;
}
else{
cout<<top+1<<endl;
}
break;
}
// int y = 2*i-1;
// if(i>4){
// y = 2*(9-i)-1;
// }
for(int j=1;j<8;j++){
top++;
arr[top][0] = i+j;
arr[top][1] = i-j;
if(i+j == 8 || i-j == 1)
break;
}
for(int j=1;j<8;j++){
top++;
arr[top][0] = i-j;
arr[top][1] = i+j;
if(i+j == 8 || i-j == 1)
break;
}
top++;
arr[top][0] = i;
arr[top][1] = i;
}
for(int i=0;i<top+1;i++){
if(i == top && x == 8)
break;
cout<<arr[i][0]<<" "<<arr[i][1]<<endl;
}
top = -1;
}
return 0;
}