結果

問題 No.539 インクリメント
ユーザー y_taira_cy_taira_c
提出日時 2017-07-02 14:09:15
言語 C++11
(gcc 11.4.0)
結果
OLE  
実行時間 -
コード長 1,965 bytes
コンパイル時間 882 ms
コンパイル使用メモリ 71,632 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2024-04-15 11:57:44
合計ジャッジ時間 2,333 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS

#include <algorithm>
#include <iostream>
#include <set>
#include <string>
#include <vector>


using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define REP(i,n) for(ll i=0; i<n; ++i )
#define REPR(i,n) for( ll i=n; i>=0; --i)
#define REPS(i,n,s) for(ll i=0; i<n; i+=s )
#define REPSR(i,n,s) for( ll i=n; i>=0; i-=s)
#define FOR(i,a,n) for(ll i=a; i<n; ++i )
#define FORR(i,a,n) for(ll i=n; i>=a; --i)
#define FORS(i,a,n,s) for(ll i=a; i<n; i+=s )
#define FORSR(i,a,n,s) for(ll i=n; i>=a; i-=s)

#define VDOUT(x) cerr << #x << "\n";for(auto i : x ) cerr << "  " << i << "\n";
#define DOUT(x) cerr << #x << " = " << x << "\n";

#define COUT(x) cout << x << "\n";
#define COUT2(x,y) cout <<x << " " << y << "\n";
#define COUT3(x,y,z) cout <<x << " " << y << " " << z << "\n"; 

#define INI ios::sync_with_stdio(false);cin.tie(0)


#define ALL(x) x.begin(),x.end()


int main()
{
	INI;
	
	int n;
	cin >> n;
	cin.ignore();
	string num, txt_s, txt_e;
	REP(loop,n)
	{
		string s;
		getline(cin, s);

		vector<string> vs;
		REPS(keta, s.length(), 1000)
		{
			int sz = s.length() > keta + 1000 ? keta + 1000 : s.length();
			vs.push_back(s.substr(keta, sz));
		}
		REPR(i, vs.size()-1)
		{
			num = "";
			txt_s = "";
			txt_e = "";
			REPR(er, vs[i].length() - 1)
			{
				if (vs[i][er] >= '0' && vs[i][er] <= '9')
				{
					num = vs[i][er] + num;
				}
				else if (num != "")
				{
					txt_s = vs[i].substr(0, er + 1);
					break;
				}
				else
				{
					txt_e = vs[i][er] + txt_e;
				}
			}

			bool flag = true;
			if (num != "")
			{
				string tnum = to_string(stoull(num) + 1);
				int c = num.length() - tnum.length();
				REP(k, c)
				{
					tnum = "0" + tnum;
				}
				if (num.length() < tnum.length())flag = false;
				num = tnum;
			}
			vs[i] = txt_s + num + txt_e;

			if (txt_s != "" || !flag) break;
		}
		REP(i, vs.size())
		{
			cout << vs[i];
		}
		cout << "\n";
	}
	return 0;
}
0