結果
| 問題 | No.3677 Global Checksum |
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2026-09-05 11:58:44 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 64 ms / 200 ms |
| + 493µs | |
| コード長 | 1,737 bytes |
| 記録 | |
| コンパイル時間 | 112 ms |
| コンパイル使用メモリ | 41,400 KB |
| 実行使用メモリ | 59,960 KB |
| 最終ジャッジ日時 | 2026-09-05 14:30:55 |
| 合計ジャッジ時間 | 11,074 ms |
|
ジャッジサーバーID (参考情報) |
judge5_0 / judge7_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
ソースコード
#include <cstdint>
#include <unistd.h>
using uint = uint32_t;
constexpr size_t IN_SIZE = 1 << 26; // 64 MiB
constexpr size_t OUT_SIZE = 12'000'000; // 11 MB あれば足りる
static char ibuf[IN_SIZE];
static char obuf[OUT_SIZE];
static uint S[1'000'000];
inline uint read_uint(char *&p) {
while (*p < '0') {
++p;
}
uint x = 0;
while (*p >= '0') {
x = x * 10 + static_cast<uint>(*p - '0');
++p;
}
return x;
}
int main() {
// 入力を全部読む
size_t len = 0;
while (true) {
ssize_t n = ::read(
STDIN_FILENO,
ibuf + len,
IN_SIZE - len - 1
);
if (n <= 0) break;
len += static_cast<size_t>(n);
}
ibuf[len] = '\0';
char *p = ibuf;
uint H = read_uint(p);
uint W = read_uint(p);
uint T = 0;
for (uint i = 0; i < H; ++i) {
uint s = 0;
for (uint j = 0; j < W; ++j) {
s += read_uint(p);
}
S[i] = s;
T += s;
}
// 出力も全部メモリ上で作る
size_t pos = 0;
for (uint i = 0; i < H; ++i) {
uint x = S[i] + T;
char tmp[10];
int n = 0;
do {
uint q = x / 10;
tmp[n++] = static_cast<char>('0' + (x - q * 10));
x = q;
} while (x);
while (n) {
obuf[pos++] = tmp[--n];
}
obuf[pos++] = '\n';
}
// 出力
size_t written = 0;
while (written < pos) {
ssize_t n = ::write(
STDOUT_FILENO,
obuf + written,
pos - written
);
if (n <= 0) break;
written += static_cast<size_t>(n);
}
return 0;
}