結果
| 問題 |
No.1617 Palindrome Removal
|
| コンテスト | |
| ユーザー |
silversmith
|
| 提出日時 | 2021-07-26 00:29:37 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 973 bytes |
| コンパイル時間 | 21,270 ms |
| コンパイル使用メモリ | 378,124 KB |
| 実行使用メモリ | 6,016 KB |
| 最終ジャッジ日時 | 2024-07-21 09:02:52 |
| 合計ジャッジ時間 | 17,287 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 17 WA * 3 |
コンパイルメッセージ
warning: variable `S` should have a snake case name
--> src/main.rs:11:6
|
11 | let S=getline();
| ^ help: convert the identifier to snake case (notice the capitalization): `s`
|
= note: `#[warn(non_snake_case)]` on by default
warning: variable `S` should have a snake case name
--> src/main.rs:12:6
|
12 | let S=S.trim();
| ^ help: convert the identifier to snake case (notice the capitalization): `s`
warning: variable `mS` should have a snake case name
--> src/main.rs:42:7
|
42 | let mS = format!("{}{}", &S[..S.len()/2], &S[S.len()/2+2..]);
| ^^ help: convert the identifier to snake case: `m_s`
ソースコード
use std::collections::HashSet;
use std::process;
fn getline() -> String{
let mut __ret=String::new();
std::io::stdin().read_line(&mut __ret).ok();
return __ret;
}
fn main() {
let S=getline();
let S=S.trim();
if S.len() == 1 {
print!("{}", -1);
process::exit(0);
}
let rev:String = S.chars().rev().collect();
if S != rev {
print!("{}", S.len());
process::exit(0);
}
if S.len() == 2 {
print!("{}", -1);
process::exit(0);
}
let char_set: HashSet<_> = S.chars().collect();
let char_num = char_set.len();
if char_num == 1 {
print!("{}", -1);
process::exit(0);
}
if S.len() % 2 == 0 {
print!("{}", S.len() -2);
process::exit(0);
}else {
let mS = format!("{}{}", &S[..S.len()/2], &S[S.len()/2+2..]);
let m_char_set: HashSet<_> = mS.chars().collect();
let m_char_num = m_char_set.len();
if m_char_num == 1 {
print!("{}", S.len() -2);
process::exit(0);
}else {
print!("{}", S.len() -2);
process::exit(0);
}
}
}
silversmith