結果

問題 No.539 インクリメント
ユーザー newlife171128newlife171128
提出日時 2018-01-30 22:52:52
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,631 bytes
コンパイル時間 1,203 ms
コンパイル使用メモリ 149,316 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-28 16:42:48
合計ジャッジ時間 2,602 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 43 ms
4,380 KB
testcase_02 WA -
testcase_03 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;

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;
		}

		if(final_right+final_left !=len){
		cout<<s.substr(final_left+final_right)<<endl;
		}else {
			cout<<endl;
		}


	}
}
0