結果

問題 No.2234 palindromer
ユーザー eroge_mastereroge_master
提出日時 2023-05-01 01:23:17
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 505 bytes
コンパイル時間 16,771 ms
コンパイル使用メモリ 377,104 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-30 03:11:37
合計ジャッジ時間 15,822 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 WA -
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 1 ms
5,376 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

use proconio::input;

fn main() {
    input! {
        a: String,
    }

    // 回文確認
    pub fn is_palindrome(s: &str) -> bool {
        s.chars().rev().collect::<String>() == s
    }

    // もし回文ならば、aをそのまま出力する。そうでなければ、aにaの末尾を削除して追加する。
    if is_palindrome(&a) {
        println!("{}", a);
    } else {
        let mut a = a;
        a.pop();
        println!("{}{}", a, a.chars().rev().collect::<String>());
    }
}
0