結果
問題 | No.927 Second Permutation |
ユーザー |
|
提出日時 | 2024-06-02 23:28:24 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 13 ms / 2,000 ms |
コード長 | 445 bytes |
コンパイル時間 | 16,064 ms |
コンパイル使用メモリ | 379,712 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-23 10:27:34 |
合計ジャッジ時間 | 17,560 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
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] != c[0] {c.swap(i, i - 1);break;}}println!("{}", c.iter().rev().collect::<String>())}