-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1780.js
57 lines (44 loc) · 1.29 KB
/
1780.js
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
var readline = require("readline");
var r = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
let input = [];
r.on("line", function (line) {
input.push(line);
}).on("close", function () {
main(input);
process.exit();
});
let arr = []
const count = {
"-1": 0,
"0": 0,
"1": 0
}
function findPage(x, y, step) {
let temp = arr[y][x]
for (let i = y; i < y + step; i++) {
for (let j = x; j < x + step; j++) {
if(temp !== arr[i][j]){
findPage(x, y, step / 3);
findPage(x + step / 3, y, step / 3)
findPage(x + step / 3 * 2, y, step / 3)
findPage(x, y + step / 3, step / 3);
findPage(x + step / 3, y + step / 3, step / 3)
findPage(x + step / 3 * 2, y + step / 3, step / 3)
findPage(x, y + step / 3 * 2, step / 3);
findPage(x + step / 3, y + step / 3 * 2, step / 3)
findPage(x + step / 3 * 2, y + step / 3 * 2, step / 3)
return
}
}
}
++count[temp];
}
function main(input) {
const N = Number(input.shift())
arr = input.map((val) => val.split(" "))
findPage(0,0, N);
console.log(`${count["-1"]}\n${count["0"]}\n${count["1"]}`);
}