-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhyperstring.js
More file actions
executable file
·51 lines (46 loc) · 876 Bytes
/
Copy pathhyperstring.js
File metadata and controls
executable file
·51 lines (46 loc) · 876 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
50
51
#!/usr/bin/env node
function processData(input) {
//Enter your code here
var lines = input.split(/\r?\n/)
var arr = lines[0].split(' ').map(Number)
var N = arr[0]
var M = arr[1]
var i = 1
var ss = []
while(i <= N) {
ss.push(lines[i])
i += 1
}
var res = []
var hs = '';
i = 0
var solutions = 1
while(i >= 0) {
if (res[i] == undefined) {
res[i] = 0
}
hs = res.slice(0, i+1).map(function(a){return ss[a]}).join('')
if (hs.length <= M) {
solutions += 1
i += 1
} else {
do {
delete res[i]
i -= 1
res[i] += 1
} while (res[i] >= N && i >= 0)
}
}
//#2 929267708
//#3 167388485
console.log(solutions % 1000000007)
}
process.stdin.resume();
process.stdin.setEncoding("ascii");
_input = "";
process.stdin.on("data", function (input) {
_input += input;
});
process.stdin.on("end", function () {
processData(_input);
});