結果
問題 | No.539 インクリメント |
ユーザー |
![]() |
提出日時 | 2018-01-30 23:48:58 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 53 ms / 2,000 ms |
コード長 | 1,921 bytes |
コンパイル時間 | 1,589 ms |
コンパイル使用メモリ | 163,816 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-29 21:54:36 |
合計ジャッジ時間 | 2,633 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 3 |
ソースコード
#include <bits/stdc++.h>#include "bits/stdc++.h"#include <iostream>#include <iomanip>#include <vector>#include <algorithm>#include <string>#include <sstream>#include <cmath>#include <stack>#include <queue>#include <cctype>#include <stdio.h>#include <map>#include <string.h>#include <utility>typedef long long ll;#define INF (1e9+1)#define rep(i,n) for(ll i=0;i<(ll)(n);i++)using namespace std;typedef pair<int, int> P;string inc(string s) {int d = 1;int n = s.length();rep(i, n) {int c = s[n - 1 - i] - '0' + d;d = c / 10;c = c % 10;s[n - 1 - i] = char('0' + c);}if (0 < d) s = char('0' + d) + s;return s;}int main() {int n;cin >> n;cin.ignore();rep(i,n){string s;getline(cin, s);int len = s.length();int left = 0;int judge = 0;/* cout << s << endl;*/string tmp = "";int final_left = 0, final_right = 0;int last =0;for (int right = left; right < len; right++) {if ('0' <= s[right] && s[right] <= '9') {judge = 1;last =1;if (right == len - 1) {tmp = s.substr(left, right - left + 1);final_left = left;final_right = right - left + 1;/* cout << s.substr(left, right-left+1) << endl;*/}} else {if (judge) {tmp = s.substr(left, right - left);final_left = left;final_right = right - left;/* cout << s.substr(left, right-left) << endl;*/judge =0;}left = right + 1;}}/*stringstream ss;ss<<tmp;int x=0;ss>>x;string xs;ss>>xs;*/cout << s.substr(0, final_left) /*<< endl*/;/*cout << s.substr(final_left, final_right);*/if(last){/*cout<<setfill('0')<< setw(tmp.length()-xs.length())<< x+1;*/cout<<inc(tmp);}if(final_right+final_left !=len){cout<<s.substr(final_left+final_right)<<endl;}else {cout<<endl;}}}