結果

問題 No.2234 palindromer
ユーザー eroge_mastereroge_master
提出日時 2023-04-30 18:08:04
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 619 bytes
コンパイル時間 12,906 ms
コンパイル使用メモリ 377,668 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 23:11:56
合計ジャッジ時間 14,016 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
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 std::io::{self, BufRead};

fn main() {
    let stdin = io::stdin();
    let mut lines = stdin.lock().lines();
    let line = lines.next().unwrap().unwrap();
    let mut iter = line.split_whitespace();

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

    // input string
    let s = iter.next().unwrap();
    let s = s.to_string();

    // if s is palindrome, print s, else print s+reverse(s)
    if is_palindrome(&s) {
        println!("{}", s);
    } else {
        println!("{}{}", s, s.chars().rev().collect::<String>());
    }
}
0