結果
| 問題 | No.539 インクリメント | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2019-04-18 11:10:59 | 
| 言語 | D (dmd 2.109.1) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,126 bytes | 
| コンパイル時間 | 901 ms | 
| コンパイル使用メモリ | 116,044 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-06-22 00:44:24 | 
| 合計ジャッジ時間 | 2,577 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | WA * 1 | 
| other | AC * 1 WA * 2 | 
ソースコード
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;
bool is_num(dchar x) {
    return '0' <= x && x <= '9';
}
bool is_ten(dchar x) {
    return x - '0' == 10;
}
void solve() {
    auto S = ('a' ~ readln.chomp).to!(dchar[]);
    int status = 0;
    int carry = 0;
    dchar increment(dchar x) {
        if ((x + 1).is_ten) {
            carry = 1;
            return '0';
        } else {
            return x + 1;
        }
    }
    foreach_reverse (i; 0..S.length.to!int) {
        if (status == 0 && S[i].is_num) {
            status = 1;
            S[i] = increment(S[i]);
        } else if (status == 1 && S[i].is_num) {
            if (carry) {
                S[i] = increment(S[i]);
            }
        } else if (status == 1 && !S[i].is_num) {
            if (carry) {
                S = S[0..i+1] ~ '1' ~ S[i+1..$];
            }
            break;
        }
    }
    S[1..$].writeln;
}
void main(){
    auto T = readln.chomp.to!int;
    while (T--) solve;
}
            
            
            
        