結果

問題 No.1617 Palindrome Removal
ユーザー silversmithsilversmith
提出日時 2021-07-26 00:29:37
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 973 bytes
コンパイル時間 3,649 ms
コンパイル使用メモリ 159,812 KB
実行使用メモリ 7,736 KB
最終ジャッジ日時 2023-09-28 14:21:58
合計ジャッジ時間 5,199 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
6,224 KB
testcase_01 WA -
testcase_02 AC 33 ms
7,616 KB
testcase_03 AC 33 ms
5,864 KB
testcase_04 AC 34 ms
6,092 KB
testcase_05 AC 28 ms
4,976 KB
testcase_06 AC 5 ms
4,380 KB
testcase_07 AC 3 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 33 ms
7,736 KB
testcase_11 AC 16 ms
4,380 KB
testcase_12 AC 19 ms
4,672 KB
testcase_13 AC 20 ms
4,684 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 WA -
testcase_17 AC 1 ms
4,380 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: variable `S` should have a snake case name
  --> 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
  --> 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
  --> 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`

warning: 3 warnings emitted

ソースコード

diff #

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);
		}
	}
}
0