結果
| 問題 | 
                            No.927 Second Permutation
                             | 
                    
| コンテスト | |
| ユーザー | 
                             特命ログイン
                         | 
                    
| 提出日時 | 2019-11-22 23:04:01 | 
| 言語 | Rust  (1.83.0 + proconio)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 715 bytes | 
| コンパイル時間 | 14,759 ms | 
| コンパイル使用メモリ | 379,948 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-10-11 04:41:21 | 
| 合計ジャッジ時間 | 14,130 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 10 WA * 17 | 
ソースコード
use std::io::{Read, stdin};
fn main() {
    let mut buf = String::new();
    stdin().read_to_string(&mut buf).unwrap();
    let mut tok = buf.split_whitespace();
    let mut get = || tok.next().unwrap();
    
    let mut x = get()
        .as_bytes()
        .iter()
        .cloned()
        .collect::<Vec<_>>();
    x.sort();
    let find = x
        .iter()
        .enumerate()
        .find(|(_,s)| **s != x[0]);
    let ans = match find {
        None => "-1".to_string(),
        Some((i, _)) if i+1 == x.len() =>
            "-1".to_string(),
        Some((i, _)) => {
            x.swap(0, i);
            x.reverse();
            String::from_utf8(x).unwrap()
        }
    };
    println!("{}", ans);
}
            
            
            
        
            
特命ログイン