結果
問題 | No.927 Second Permutation |
ユーザー |
|
提出日時 | 2024-06-02 23:54:31 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 9 ms / 2,000 ms |
コード長 | 348 bytes |
コンパイル時間 | 15,091 ms |
コンパイル使用メモリ | 381,364 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-23 10:29:03 |
合計ジャッジ時間 | 12,869 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
fn main() {let mut s = String::new();std::io::stdin().read_line(&mut s).ok();let mut c: Vec<_> = s.trim().chars().collect();c.sort();if let Some(p) = c.iter().position(|&x| x != c[0]) {if c[0] != '0' || p != c.len() - 1 {c.swap(p - 1, p);println!("{}", c.iter().rev().collect::<String>());return;}}println!("-1");}