結果

問題 No.3677 Global Checksum
コンテスト
ユーザー 👑 みうね
提出日時 2026-09-05 11:50:06
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 72 ms / 200 ms
+ 40µs
コード長 2,115 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 288 ms
コンパイル使用メモリ 75,152 KB
実行使用メモリ 9,740 KB
最終ジャッジ日時 2026-09-05 14:30:28
合計ジャッジ時間 13,374 ms
ジャッジサーバーID
(参考情報)
judge7_0 / judge6_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <vector>
#include <cstdint>
#include <cstdio>

struct FastScanner {
    static constexpr size_t BUF_SIZE = 1 << 20;
    char inbuf[BUF_SIZE];
    size_t in_pos = 0;
    size_t in_len = 0;

    inline char get_char() {
        if (in_pos >= in_len) {
            in_pos = 0;
            in_len = fread(inbuf, 1, BUF_SIZE, stdin);
        }
        return inbuf[in_pos++];
    }

    inline uint32_t read_uint() {
        uint32_t x = 0;
        char c = get_char();

        while (c < '0' || c > '9') {
            c = get_char();
        }

        while ('0' <= c && c <= '9') {
            x = x * 10 + static_cast<uint32_t>(c - '0');
            c = get_char();
        }

        return x;
    }
};

struct FastPrinter {
    static constexpr size_t BUF_SIZE = 1 << 20;
    char outbuf[BUF_SIZE];
    size_t out_pos = 0;

    inline void flush() {
        if (out_pos > 0) {
            fwrite(outbuf, 1, out_pos, stdout);
            out_pos = 0;
        }
    }

    inline void write_uint(uint32_t x) {
        if (out_pos + 16 >= BUF_SIZE) {
            flush();
        }

        if (x == 0) {
            outbuf[out_pos++] = '0';
            outbuf[out_pos++] = '\n';
            return;
        }

        char temp[10];
        int len = 0;

        while (x > 0) {
            uint32_t q = x / 10;
            temp[len++] = static_cast<char>('0' + (x - q * 10));
            x = q;
        }

        while (len > 0) {
            outbuf[out_pos++] = temp[--len];
        }
        outbuf[out_pos++] = '\n';
    }

    ~FastPrinter() {
        flush();
    }
};

int main() {
    static FastScanner scanner;
    static FastPrinter printer;

    uint32_t H = scanner.read_uint();
    uint32_t W = scanner.read_uint();

    std::vector<uint32_t> S(H);

    uint32_t T = 0;

    for (uint32_t i = 0; i < H; ++i) {
        uint32_t row_sum = 0;

        for (uint32_t j = 0; j < W; ++j) {
            row_sum += scanner.read_uint();
        }

        S[i] = row_sum;
        T += row_sum;
    }

    for (uint32_t i = 0; i < H; ++i) {
        printer.write_uint(S[i] + T);
    }

    return 0;
}
0