-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshopee1.js
executable file
·65 lines (62 loc) · 1.32 KB
/
shopee1.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
58
59
60
61
62
63
64
65
var readline = require("readline");
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
terminal: false
});
let cur_line = 0,
n,
target,
method = 0,
arr = [];
let cmp = a => {
for (let i = 0; i < arr.length; i++) {
if (a[0] === arr[i][0] && a[0] === [i][1]) {
return false;
}
}
return true; //same loc
};
let F = (x, y) => {
console.log(x, y);
let loc = [x, y];
if (x > target[0] || y > target[1]) {
return method;
}
if (x === target[0] && y === target[1]) {
method++;
console.log(`method num is ${method}`);
return;
}
if (!cmp(loc)) {
console.log(`boss!`);
return;
} else {
// if (x + 1 !== target[0] && y !== target[1])
F(x + 1, y);
console.log(`entering 1`);
// if (x !== target[0] && y + 1 !== target[1])
F(x, y + 1);
console.log(`entering 2`);
}
};
rl.on("line", function(line) {
if (n == undefined) {
const [x, y, z] = line.split(" ");
n = z;
target = [x, y];
console.log(arr);
cur_line++;
console.log(x, y, n);
} else {
if (cur_line <= n) {
const [x, y] = line.split(" ");
arr.push([x, y]);
console.log(arr);
cur_line++;
} else {
console.log(target);
F(0, 0);
}
}
});