結果

問題 No.3677 Global Checksum
コンテスト
ユーザー harurun
提出日時 2026-09-04 23:20:18
言語 C++23(gcc16)
(gcc 16.1.0 + boost 1.92.0)
コンパイル:
g++-16 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 73 ms / 200 ms
+ 714µs
コード長 2,051 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 321 ms
コンパイル使用メモリ 80,340 KB
実行使用メモリ 9,792 KB
最終ジャッジ日時 2026-09-04 23:20:29
合計ジャッジ時間 5,037 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge4_0
外部呼び出し有り
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

using u32 = uint32_t;

class FastInput {
    static constexpr size_t BUF_SIZE = 1 << 20;
    char buf[BUF_SIZE];
    size_t pos = 0, len = 0;

    inline char getChar() {
        if (pos == len) {
            len = std::fread(buf, 1, BUF_SIZE, stdin);
            pos = 0;
            if (len == 0) return '\0';
        }
        return buf[pos++];
    }

public:
    inline u32 readUInt() {
        char c = getChar();

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

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

        return x;
    }
};

class FastOutput {
    static constexpr size_t BUF_SIZE = 1 << 20;
    char buf[BUF_SIZE];
    size_t pos = 0;

public:
    ~FastOutput() {
        flush();
    }

    inline void flush() {
        if (pos) {
            std::fwrite(buf, 1, pos, stdout);
            pos = 0;
        }
    }

    inline void writeUInt(u32 x) {
        char tmp[10];
        int n = 0;

        do {
            tmp[n++] = static_cast<char>('0' + x % 10);
            x /= 10;
        } while (x);

        if (pos + static_cast<size_t>(n) + 1 > BUF_SIZE) {
            flush();
        }

        while (n--) {
            buf[pos++] = tmp[n];
        }
        buf[pos++] = '\n';
    }
};

int main() {
    FastInput in;
    FastOutput out;

    const u32 H = in.readUInt();
    const u32 W = in.readUInt();

    // S_i を保存する。
    // H <= 10^6 なので最大でも約 4 MB。
    std::vector<u32> S(H);

    u32 T = 0;

    for (u32 i = 0; i < H; ++i) {
        u32 s = 0;

        for (u32 j = 0; j < W; ++j) {
            const u32 a = in.readUInt();
            s += a;  // 自動的に mod 2^32
        }

        S[i] = s;
        T += s;      // 自動的に mod 2^32
    }

    for (u32 i = 0; i < H; ++i) {
        const u32 C = S[i] + T;  // 自動的に mod 2^32
        out.writeUInt(C);
    }

    return 0;
}
0