- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNote.php
More file actions
Latest commit
32 lines (28 loc) · 685 Bytes
/
Copy pathNote.php
File metadata and controls
32 lines (28 loc) · 685 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
<?php
/**
* @author Sunwaurl
* PHP 7.2
*/
error_reporting(0);
$stdin = fopen("php://stdin", "r");
$arr = array();
$res = 0;
for ($i = 0; $i <= 4; $i++) {
fscanf($stdin, "%[^\n]", $arr_temp);
$arr[] = array_map('intval', preg_split('/ /', $arr_temp, -1, PREG_SPLIT_NO_EMPTY));
}
for ($i = 0; $i <= 4; $i++) {
for ($j = 0; $j <= 4; $j++) {
if ($i == 0 && $j == 0) {
if ($arr[$i][$j] == 1) {
$res = 4;
} else {
$res = 0;
}
} elseif ($arr[$i][$j] == 1) {
$res = abs($i - 2) + abs($j - 2);
}
}
}
echo$res . "\n";
fclose($stdin);