結果

問題 No.3677 Global Checksum
コンテスト
ユーザー 秋ナス🍆
提出日時 2026-09-05 09:59:35
言語 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
結果
TLE  
実行時間 -
コード長 2,889 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,173 ms
コンパイル使用メモリ 171,188 KB
実行使用メモリ 8,192 KB
最終ジャッジ日時 2026-09-05 09:59:44
合計ジャッジ時間 5,902 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12 TLE * 1 -- * 7
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:103:21: warning: 'val' may be used uninitialized [-Wmaybe-uninitialized]
  103 |             row_sum += val; // 自動的に mod 2^32
      |             ~~~~~~~~^~~~~~
main.cpp:101:22: note: 'val' was declared here
  101 |             uint32_t val;
      |                      ^~~

ソースコード

diff #
raw source code

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

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

    inline bool skip_whitespace() {
        while (true) {
            if (in_pos >= in_len) {
                in_pos = 0;
                in_len = fread(inbuf, 1, BUF_SIZE, stdin);
                if (in_len == 0) return false;
            }
            while (in_pos < in_len && static_cast<unsigned char>(inbuf[in_pos]) <= ' ') {
                in_pos++;
            }
            if (in_pos < in_len) return true;
        }
    }

    inline bool read_uint(uint32_t& x) {
        if (!skip_whitespace()) return false;
        x = 0;
        while (true) {
            while (in_pos < in_len) {
                char c = inbuf[in_pos];
                if (c < '0' || c > '9') {
                    return true;
                }
                x = x * 10 + static_cast<uint32_t>(c - '0');
                in_pos++;
            }
            in_pos = 0;
            in_len = fread(inbuf, 1, BUF_SIZE, stdin);
            if (in_len == 0) break;
        }
        return true;
    }
};

struct FastPrinter {
    static constexpr size_t BUF_SIZE = 1 << 20; // 1MB
    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) {
        // 数値1つ + 改行を出力するのに十分な空きがない場合はフラッシュ
        if (out_pos + 16 >= BUF_SIZE) {
            flush();
        }
        if (x == 0) {
            outbuf[out_pos++] = '0';
            outbuf[out_pos++] = '\n';
            return;
        }
        char temp[12];
        int len = 0;
        while (x > 0) {
            temp[len++] = static_cast<char>('0' + (x % 10));
            x /= 10;
        }
        while (len > 0) {
            outbuf[out_pos++] = temp[--len];
        }
        outbuf[out_pos++] = '\n';
    }

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

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);

    static FastScanner scanner;
    static FastPrinter printer;

    uint32_t H, W;
    if (!scanner.read_uint(H) || !scanner.read_uint(W)) return 0;

    std::vector<uint32_t> S(H, 0);
    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) {
            uint32_t val;
            scanner.read_uint(val);
            row_sum += val; // 自動的に mod 2^32
        }
        S[i] = row_sum;
        T += row_sum;      // 自動的に mod 2^32
    }

    for (uint32_t i = 0; i < H; ++i) {
        printer.write_uint(S[i] + T); // 自動的に mod 2^32
    }

    return 0;
}
0