Task: | Ositus |
Sender: | Mixu_78 |
Submission time: | 2021-10-05 17:10:35 +0300 |
Language: | Node.js |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
#2 | WRONG ANSWER | 0 |
#3 | WRONG ANSWER | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | WRONG ANSWER | 0.43 s | 1, 2, 3 | details |
#2 | WRONG ANSWER | 0.46 s | 1, 2, 3 | details |
#3 | WRONG ANSWER | 0.46 s | 1, 2, 3 | details |
#4 | WRONG ANSWER | 0.45 s | 1, 2, 3 | details |
#5 | TIME LIMIT EXCEEDED | -- | 2, 3 | details |
#6 | RUNTIME ERROR | 0.44 s | 3 | details |
#7 | RUNTIME ERROR | 0.44 s | 3 | details |
Code
const fs = require("fs"); const str = fs.existsSync("./subIn.txt") ? fs.readFileSync("./subIn.txt").toString() : fs.readFileSync(0).toString(); /** * @param {string} str * @returns {Generator<string[]>} */ function* partitions(str) { if (str.length > 0) { for (let i = 1; i < str.length + 1; i++) { const a = str.slice(0, i); const rest = str.slice(i); for (const p of partitions(rest)) { yield [a, ...p]; } } } else { yield []; } } /**@param {string} s */ const hasDuplicate = (s) => { for (let i = 0; i < s.length; i++) { if (s.lastIndexOf(s[i]) !== i) return true; } return false; } let total = 0; for (const part of partitions(str)) { const ok = part.every((s) => !hasDuplicate(s)); if (ok) total++; } console.log(total)
Test details
Test 1
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
a |
correct output |
---|
1 |
user output |
---|
2 |
Test 2
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
abcdefghij |
correct output |
---|
512 |
user output |
---|
1024 |
Test 3
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
abcabaacbc |
correct output |
---|
120 |
user output |
---|
240 |
Test 4
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
aaxxxxxxaa |
correct output |
---|
4 |
user output |
---|
8 |
Test 5
Group: 2, 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
mfyzvoxmppoxcvktmcjkryyocfweub... |
correct output |
---|
643221148 |
user output |
---|
(empty) |
Test 6
Group: 3
Verdict: RUNTIME ERROR
input |
---|
weinscqmmpgbrlboocvtbptgbahmwv... |
correct output |
---|
831644159 |
user output |
---|
(empty) |
Error:
/box/input/code.js:1 (function (exports, require, module, __filename, __dirname) { const f...
Test 7
Group: 3
Verdict: RUNTIME ERROR
input |
---|
sxaoxcyrjoeieyinaqxwukgzdnhhsw... |
correct output |
---|
816016015 |
user output |
---|
(empty) |
Error:
/box/input/code.js:1 (function (exports, require, module, __filename, __dirname) { const f...