| Task: | Ositus |
| Sender: | Mixu_78 |
| Submission time: | 2021-10-05 17:24:29 +0300 |
| Language: | Node.js |
| Status: | READY |
| Result: | 40 |
| group | verdict | score |
|---|---|---|
| #1 | ACCEPTED | 40 |
| #2 | TIME LIMIT EXCEEDED | 0 |
| #3 | TIME LIMIT EXCEEDED | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | ACCEPTED | 0.44 s | 1, 2, 3 | details |
| #2 | ACCEPTED | 0.46 s | 1, 2, 3 | details |
| #3 | ACCEPTED | 0.46 s | 1, 2, 3 | details |
| #4 | ACCEPTED | 0.46 s | 1, 2, 3 | details |
| #5 | TIME LIMIT EXCEEDED | -- | 2, 3 | details |
| #6 | RUNTIME ERROR | 0.44 s | 3 | details |
| #7 | RUNTIME ERROR | 0.45 s | 3 | details |
Code
const fs = require("fs");
const readline = require("readline");
const str = fs.existsSync("./subIn.txt") ? fs.readFileSync("./subIn.txt").toString() : "";
const stdin = readline.createInterface({
input: process.stdin,
});
/**
* @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;
}
const getTotal = (s) => {
if (s.length > 0) {
let total = 0;
for (const part of partitions(s)) {
const ok = part.every((s) => !hasDuplicate(s));
if (ok) total++;
}
return total;
}
}
if (str.length > 0) {
console.log(getTotal(str));
stdin.close();
} else {
stdin.on("line", (l) => {
console.log(getTotal(l))
stdin.close();
});
}Test details
Test 1
Group: 1, 2, 3
Verdict: ACCEPTED
| input |
|---|
| a |
| correct output |
|---|
| 1 |
| user output |
|---|
| 1 |
Test 2
Group: 1, 2, 3
Verdict: ACCEPTED
| input |
|---|
| abcdefghij |
| correct output |
|---|
| 512 |
| user output |
|---|
| 512 |
Test 3
Group: 1, 2, 3
Verdict: ACCEPTED
| input |
|---|
| abcabaacbc |
| correct output |
|---|
| 120 |
| user output |
|---|
| 120 |
Test 4
Group: 1, 2, 3
Verdict: ACCEPTED
| input |
|---|
| aaxxxxxxaa |
| correct output |
|---|
| 4 |
| user output |
|---|
| 4 |
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...