結果
| 問題 | No.539 インクリメント |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-01-26 15:14:57 |
| 言語 | C++11(廃止可能性あり) (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 8 ms / 2,000 ms |
| コード長 | 1,422 bytes |
| 記録 | |
| コンパイル時間 | 2,325 ms |
| コンパイル使用メモリ | 166,652 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-16 05:09:37 |
| 合計ジャッジ時間 | 3,519 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 3 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:52:9: warning: ‘char* gets(char*)’ is deprecated [-Wdeprecated-declarations]
52 | gets(S);
| ~~~~^~~
In file included from /usr/include/stdio.h:894,
from /usr/include/c++/11/cstdio:42,
from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:46,
from main.cpp:3:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:240:1: note: declared here
240 | gets (char *__str)
| ^~~~
main.cpp:52:9: warning: ignoring return value of ‘char* gets(char*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
52 | gets(S);
| ~~~~^~~
/usr/bin/ld: /tmp/cctdGBDL.o: in function `main':
main.cpp:(.text.startup+0x29): 警告: the `gets' function is dangerous and should not be used.
ソースコード
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#include "bits/stdc++.h"
using namespace std;
// #define int long long
#define REPI(i) for (int i = 0;; i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORR(i, a, b) for (int i = (b - 1); i >= (a); i--)
#define ALL(a) begin(a), end(a)
#define let const auto
int scan() {
int result = 0;
while (true) {
auto k = getchar_unlocked();
if (k < '0' || k > '9') return result;
result = 10 * result + k - '0';
}
}
char S[100010];
void reduce(int x, int y, int size) {
if (x == -1) {
puts(S);
return;
}
let sx = S[x];
let sy = S[y];
S[x] = '\0';
S[y] = '\0';
fputs(S, stdout);
S[y] = sy;
S[x] = sx;
auto carry = 1;
FORR(i, x, y + 1) {
let c = S[i] - '0';
let d = c + carry;
if (d < 10) {
S[i] = "0123456789"[d];
carry = 0;
} else {
S[i] = '0';
carry = 1;
}
}
if (carry == 1) putchar_unlocked('1');
puts(S + x);
}
signed main() {
let n = scan();
REP(_, n) {
gets(S);
auto i = 0;
auto x = -1;
auto y = -1;
auto preIsAlpha = true;
REPI(i) {
let k = S[i];
if (k == '\0') {
reduce(x, y, i);
break;
}
let isAlpha = k < '0' || '9' < k;
if (!isAlpha) {
y = i;
if (preIsAlpha) x = i;
}
preIsAlpha = isAlpha;
}
}
}