結果
問題 |
No.927 Second Permutation
|
ユーザー |
|
提出日時 | 2024-06-02 23:43:27 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 9 ms / 2,000 ms |
コード長 | 334 bytes |
コンパイル時間 | 17,260 ms |
コンパイル使用メモリ | 379,736 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-23 10:27:53 |
合計ジャッジ時間 | 12,562 ms |
ジャッジサーバーID (参考情報) |
judge2 / 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(); for i in 0..c.len() { if c[i] != c[0] && (i < c.len() - 1 || c[0] != '0') { c.swap(i, i - 1); println!("{}", c.iter().rev().collect::<String>()); return; } } println!("-1"); }