結果
| 問題 |
No.539 インクリメント
|
| コンテスト | |
| ユーザー |
teketeke5000
|
| 提出日時 | 2017-10-24 20:08:01 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,289 bytes |
| コンパイル時間 | 1,627 ms |
| コンパイル使用メモリ | 164,528 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-21 17:48:16 |
| 合計ジャッジ時間 | 2,668 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 1 RE * 2 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:41:20: warning: ‘isZero’ may be used uninitialized in this function [-Wmaybe-uninitialized]
41 | if (isZero && isNine) st--;
| ~~~~~~~^~~~~~~~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,a,n) for(ll i=(a); i<(ll)(n); i++)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(v) (v).begin(), (v).end()
int main(void) {
int T;
int level;
cin >> T;
string strs[T];
cin.ignore();
for (int i=0; i<T; i++) {
string str;
bool line = false;
bool isZero;
bool isNine;
int st=0,en=0;
getline(cin, str);
for (int j=str.size()-1; j>=0; j--) {
if (!line) {
if (isdigit(str[j])) {
en = j;
line = !line;
}
} else {
if (!isdigit(str[j]) || str[j] == '0') {
isZero = str[j] == '0';
st = j+1;
break;
}
}
}
if (!line) {
strs[i] = str;
continue;
}
isNine = str.front() == '9';
level = stoi(str.substr(st, en - st + 1)) + 1;
if (isZero && isNine) st--;
strs[i] = str.substr(0, st) + to_string(level) + str.substr(en+1, str.size() - 1);
}
for (int i=0; i<T; i++) cout << strs[i] << endl;
return 0;
}
teketeke5000