結果
問題 | No.927 Second Permutation |
ユーザー |
|
提出日時 | 2024-06-02 23:26:05 |
言語 | Rust (1.83.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 440 bytes |
コンパイル時間 | 11,859 ms |
コンパイル使用メモリ | 393,872 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-12-23 10:27:17 |
合計ジャッジ時間 | 13,643 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 WA * 17 |
ソースコード
use std::collections::HashSet;fn main() {let mut s = String::new();std::io::stdin().read_line(&mut s).ok();let s = s.trim();if s.chars().filter(|&c| c != '0').count() < 2|| s.chars().collect::<HashSet<_>>().len() < 2{println!("-1");return;}let mut c: Vec<_> = s.chars().collect();c.sort();for i in 1.. {if c[i] != '0' {c.swap(0, i);break;}}println!("{}", c.iter().rev().collect::<String>())}