結果
| 問題 | No.539 インクリメント |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-01-26 15:14:57 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 6 ms / 2,000 ms |
| コード長 | 1,422 bytes |
| 記録 | |
| コンパイル時間 | 1,595 ms |
| コンパイル使用メモリ | 190,596 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-04-05 10:18:31 |
| 合計ジャッジ時間 | 2,116 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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 /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/cstdio:47,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/ext/string_conversions.h:47,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/basic_string.h:4444,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/string:56,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bitset:54,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/x86_64-pc-linux-gnu/bits/stdc++.h:54,
from main.cpp:3:
/usr/include/stdio.h:667:14: note: declared here
667 | extern char *gets (char *__s) __wur __attribute_deprecated__;
| ^~~~
/usr/bin/ld: /tmp/ccdwS5h2.o: in function `main':
main.cpp:(.text.startup+0x28): 警告: 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;
}
}
}