forked from anandadfoxx/codeforces_solutions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path263A.cpp
More file actions
49 lines (44 loc) · 985 Bytes
/
Copy path263A.cpp
File metadata and controls
49 lines (44 loc) · 985 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
42
43
44
45
46
47
48
49
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int arr[5][5],
posi, posj;
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 5; j++) {
cin >> arr[i][j];
if (arr[i][j] == 1) {
posi = i;
posj = j;
}
}
}
int ans = 0;
while (posj != 2) {
if (posj < 2) {
arr[posi][posj] = 0;
arr[posi][posj+1] = 1;
posj++;
}
else {
arr[posi][posj] = 0;
arr[posi][posj-1] = 1;
posj--;
}
ans++;
}
while (posi != 2) {
if (posi < 2) {
arr[posi][posj] = 0;
arr[posi+1][posj] = 1;
posi++;
}
else {
arr[posi][posj] = 0;
arr[posi-1][posj] = 1;
posi--;
}
ans++;
}
cout << ans << "\n";
}