| Task: | Palindromi |
| Sender: | j-l |
| Submission time: | 2025-11-01 16:31:07 +0200 |
| Language: | Node.js |
| Status: | READY |
| Result: | 0 |
| group | verdict | score |
|---|---|---|
| #1 | TIME LIMIT EXCEEDED | 0 |
| test | verdict | time | |
|---|---|---|---|
| #1 | TIME LIMIT EXCEEDED | -- | details |
| #2 | ACCEPTED | 0.11 s | details |
| #3 | ACCEPTED | 0.11 s | details |
| #4 | ACCEPTED | 0.11 s | details |
| #5 | TIME LIMIT EXCEEDED | -- | details |
| #6 | TIME LIMIT EXCEEDED | -- | details |
| #7 | TIME LIMIT EXCEEDED | -- | details |
| #8 | TIME LIMIT EXCEEDED | -- | details |
| #9 | TIME LIMIT EXCEEDED | -- | details |
| #10 | TIME LIMIT EXCEEDED | -- | details |
Code
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
function setCharAt(str, index, char) {
if (index < 0 || index >= str.length) {
return str;
}
return (str.slice0, index) + char + str.slice(index + 1);
}
function palindromi(wordOrigin){
let txtlength = 0;
let result1 = "";
let result2 = "";
while ((wordOrigin.length/2) > txtlength) {
result1 = result1+wordOrigin.charAt(txtlength);
result2 = wordOrigin.charAt(txtlength+(Math.floor(wordOrigin.length/2)))+result2;
txtlength += 1;
};
if (result1 == result2) {
return 0;
}else{
result1 = "";
result2 = "";
txtlength = 0;
let final = 0;
let char = "";
while(true){
if (wordOrigin.charAt((wordOrigin.lenght)-(txtlength+1)) != wordOrigin.charAt(txtlength)) {
char = wordOrigin.charAt(txtlength);
wordOrigin = setCharAt(wordOrigin, (wordOrigin.lenght)-(txtlength+1), String(char));
final += 1;
};
txtlength += 1;
if (wordOrigin.length == txtlength) {
break;
};
};
return final;
};
};
rl.question("", (text) => {
console.log(palindromi(text));
rl.close();
});Test details
Test 1 (public)
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| datatahti |
| correct output |
|---|
| 3 |
| user output |
|---|
| (empty) |
Test 2 (public)
Verdict: ACCEPTED
| input |
|---|
| saippuakauppias |
| correct output |
|---|
| 0 |
| user output |
|---|
| 0 |
Test 3 (public)
Verdict: ACCEPTED
| input |
|---|
| a |
| correct output |
|---|
| 0 |
| user output |
|---|
| 0 |
Test 4 (public)
Verdict: ACCEPTED
| input |
|---|
| aa |
| correct output |
|---|
| 0 |
| user output |
|---|
| 0 |
Test 5 (public)
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| abc |
| correct output |
|---|
| 1 |
| user output |
|---|
| (empty) |
Test 6 (public)
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| aybabtu |
| correct output |
|---|
| 2 |
| user output |
|---|
| (empty) |
Test 7 (public)
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| abacabaca |
| correct output |
|---|
| 2 |
| user output |
|---|
| (empty) |
Test 8 (public)
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| bbbbaaaababbbbbaabaaabaaaaabab... |
| correct output |
|---|
| 23 |
| user output |
|---|
| (empty) |
Test 9 (public)
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| acbaaabaabaddaccdcccbcdbdddacd... |
| correct output |
|---|
| 38 |
| user output |
|---|
| (empty) |
Test 10 (public)
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| uaqtmfftecryanvpshxsodjrllqnqp... |
| correct output |
|---|
| 49 |
| user output |
|---|
| (empty) |
