結果
| 問題 |
No.2234 palindromer
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-04-30 18:08:04 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 619 bytes |
| コンパイル時間 | 13,903 ms |
| コンパイル使用メモリ | 381,736 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-19 08:09:06 |
| 合計ジャッジ時間 | 14,828 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 |
| other | AC * 4 WA * 9 |
ソースコード
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>());
}
}