結果
| 問題 | No.539 インクリメント | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2020-07-24 19:47:33 | 
| 言語 | Rust (1.83.0 + proconio) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 153 ms / 2,000 ms | 
| コード長 | 1,521 bytes | 
| コンパイル時間 | 19,443 ms | 
| コンパイル使用メモリ | 384,060 KB | 
| 実行使用メモリ | 8,188 KB | 
| 最終ジャッジ日時 | 2024-06-25 18:27:35 | 
| 合計ジャッジ時間 | 18,772 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 3 | 
ソースコード
fn main() {
    let mut t = String::new();
    std::io::stdin().read_line(&mut t).ok();
    let t: usize = t.trim().parse().unwrap();
    for _ in 0..t {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).ok();
        let mut s: Vec<char> = s.trim().chars().collect();
        s.reverse();
        let mut flg = false;
        let mut flg2 = false;
        let mut result = s.iter()
            .map(|c| {
                if flg && flg2 {
                    return c.to_string();
                }
                let temp = c.to_string().parse::<usize>();
                if temp.is_ok() {
                    let temp = temp.unwrap();
                    flg = true;
                    if !flg2 {
                        if temp == 9 {
                            return "0".to_string();
                        } else {
                            flg2 = true;
                            return (temp + 1).to_string();
                        }
                    } else {
                        return c.to_string();
                    }
                } else {
                    if flg && !flg2 {
                        flg2 = true;
                        return format!("{}{}", c, 1);
                    } else {
                        return c.to_string();
                    }
                }
            })
            .collect::<Vec<String>>()
        ;
        result.reverse();
        println!("{}{}",if flg && !flg2 { "1" } else { "" }, result.join(""));
    }
}
            
            
            
        