結果
問題 | No.1617 Palindrome Removal |
ユーザー | irumo8202 |
提出日時 | 2022-02-13 12:23:44 |
言語 | TypeScript (5.4.3) |
結果 |
AC
|
実行時間 | 140 ms / 2,000 ms |
コード長 | 706 bytes |
コンパイル時間 | 7,217 ms |
コンパイル使用メモリ | 254,944 KB |
実行使用メモリ | 48,456 KB |
最終ジャッジ日時 | 2023-09-11 15:24:59 |
合計ジャッジ時間 | 12,512 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 119 ms
47,308 KB |
testcase_01 | AC | 119 ms
47,740 KB |
testcase_02 | AC | 120 ms
47,540 KB |
testcase_03 | AC | 120 ms
47,588 KB |
testcase_04 | AC | 122 ms
47,808 KB |
testcase_05 | AC | 120 ms
47,040 KB |
testcase_06 | AC | 106 ms
48,456 KB |
testcase_07 | AC | 100 ms
46,940 KB |
testcase_08 | AC | 77 ms
41,648 KB |
testcase_09 | AC | 77 ms
41,440 KB |
testcase_10 | AC | 135 ms
47,952 KB |
testcase_11 | AC | 131 ms
46,776 KB |
testcase_12 | AC | 140 ms
47,296 KB |
testcase_13 | AC | 138 ms
47,272 KB |
testcase_14 | AC | 77 ms
41,580 KB |
testcase_15 | AC | 75 ms
41,628 KB |
testcase_16 | AC | 77 ms
41,720 KB |
testcase_17 | AC | 78 ms
41,672 KB |
testcase_18 | AC | 76 ms
41,576 KB |
testcase_19 | AC | 77 ms
41,664 KB |
testcase_20 | AC | 76 ms
41,572 KB |
testcase_21 | AC | 76 ms
41,568 KB |
testcase_22 | AC | 77 ms
41,712 KB |
testcase_23 | AC | 76 ms
42,304 KB |
ソースコード
import * as fs from "fs" type Input = (args: string) => void const main: Input = args => { const input = args.trim().split("\n"); const S = input.shift() const n = S.length let isOdd = n % 2 == 1 ? true : false let flg = true let chars = new Set() for (let i = 0; i < n / 2; i++) { if (S[i] == S[n - i - 1]) { chars.add(S[i]) } else { flg = false } } if (!flg) { console.log(n) } else if (chars.size === 1) { console.log(isOdd ? -1 : 0) } else if (isOdd && n >= 5 || !isOdd) { console.log(n - 2) } else { console.log(-1) } } main(fs.readFileSync('/dev/stdin', 'utf8'));