結果
| 問題 |
No.539 インクリメント
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-07-10 23:34:01 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 21 ms / 2,000 ms |
| コード長 | 903 bytes |
| コンパイル時間 | 1,794 ms |
| コンパイル使用メモリ | 169,504 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-12 23:53:17 |
| 合計ジャッジ時間 | 3,373 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 3 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int T;
string s, t, s2;
getline(cin, s);
T = stoi(s);
while(T--){
string s, t, s2;
getline(cin, s);
while(!s.empty() && !isdigit(s.back())){
s2 += s.back();
s.pop_back();
}
while(!s.empty() && isdigit(s.back())){
t += s.back();
s.pop_back();
}
if(!t.empty()){
t[0]++;
for(int i = 0; i < t.size(); i++){
if(t[i] >= '0' + 10){
t[i] -= 10;
if(t.size() == i + 1) t += '1';
else t[i + 1]++;
}
}
}
reverse(s2.begin(), s2.end());
reverse(t.begin(), t.end());
cout << s << t << s2 << '\n';
}
}