結果

問題 No.3677 Global Checksum
コンテスト
ユーザー TKTYI
提出日時 2026-08-24 14:31:08
言語 C++23
(gcc 15.3.0 + boost 1.92.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
TLE  
実行時間 -
コード長 3,113 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,341 ms
コンパイル使用メモリ 350,796 KB
実行使用メモリ 12,544 KB
最終ジャッジ日時 2026-09-04 22:33:48
合計ジャッジ時間 6,723 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8 TLE * 4 -- * 8
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In constructor 'FastIn::FastIn()':
main.cpp:11:14: warning: '*this.FastIn::buf' is used uninitialized [-Wuninitialized]
   11 |     FastIn() {
      |              ^

ソースコード

diff #
raw source code

// https://trap.jp/post/2887/
// https://judge.yosupo.jp/submission/347372
#include <bits/stdc++.h>
#include <sys/mman.h>
#include <sys/stat.h>
using namespace std;
using ll = long long;
struct FastIn {
    char* buf;
    char* pos = buf;
    FastIn() {
        struct stat st;
        fstat(0, &st);
        buf = (char*)mmap(nullptr, st.st_size, PROT_READ, MAP_PRIVATE, 0, 0);
        pos = buf;
    }
    ll nextNum() {
        ll ret = 0;
        while (*pos < '0' || *pos > '9') pos++;
        ll tmp;
        while (1) {
            memcpy(&tmp, pos, 8);
            if ((tmp -= 0x3030303030303030) &  0x8080808080808080)
                goto end;
            tmp = (tmp * 10 + (tmp >> 8)) & 0xff00ff00ff00ff;
            tmp = (tmp * 100 + (tmp >> 16)) & 0xffff0000ffff;
            tmp = (tmp * 10000 + (tmp >> 32)) & 0xffffffff;
            ret = 1'0000'0000 * ret + tmp;
            pos += 8;
        }
end:
        while ('0' <= *pos && *pos <= '9') {
            ret = ret * 10 + (*pos - '0');
            pos++;
        }
        return ret;
    }
} fin;
static constexpr auto LUT = [] {
    array<char, 40000> res;
    char *p = res.data();
    char a = '0', b = '0', c = '0', d = '0';
    do {
        *p++ = a, *p++ = b, *p++ = c, *p++ = d;
    } while (
        d++ < '9' || (d = '0',
            c++ < '9' || (c = '0',
                b++ < '9' || (b = '0', a++ < '9')
            )
        )
    );
    return res;
}();
struct FastOut {
    char buf[1 << 26]; // 64MB
    char* pos = buf;
    ~FastOut() {
        fwrite(buf, 1, pos - buf, stdout);
    }
    int getLen(ll x) {
        if (x < 10'000) {
            if (x < 100) return x < 10 ? 1 : 2;
            return x < 1'000 ? 3 : 4;
        }
        if (x < 100'000'000) {
            if (x < 1'000'000) return x < 100'000 ? 5 : 6;
            return x < 10'000'000 ? 7 : 8;
        }
        if (x < 1'000'000'000'000LL) {
            if (x < 10'000'000'000LL) return x < 1'000'000'000LL ? 9 : 10;
            return x < 100'000'000'000LL ? 11 : 12;
        }
        if (x < 10'000'000'000'000'000LL) {
            if (x < 100'000'000'000'000LL) return x < 10'000'000'000'000LL ? 13 : 14;
            return x < 1'000'000'000'000'000LL ? 15 : 16;
        }
        if (x < 1'000'000'000'000'000'000LL) return x < 100'000'000'000'000'000LL ? 17 : 18;
        return 19;
    }
    void printNum(ll x) {
        if (x == 0) { *pos++ = '0'; return; }
        int len = getLen(x);
        char* p = pos + len;
        pos = p;
        while (x >= 10000) {
            int rem = x % 10000;
            x /= 10000;
            p -= 4;
            memcpy(p, &LUT[rem * 4], 4);
        }
        while (x >= 10) {
            *--p = (x % 10) + '0';
            x /= 10;
        }
        *--p = x + '0';
    }
} fout;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
int main(){
  int H=fin.nextNum(),W=fin.nextNum();
  vector<unsigned>S(H);
  rep(i,0,H)rep(j,0,W){
  	unsigned x=fin.nextNum();
  	S[i]+=x;
  	cerr<<"OK"<<endl;
  }
  unsigned T=reduce(S.begin(),S.end());
  rep(i,0,H){
  	fout.printNum(S[i]+T);
	*fout.pos++='\n';
  }
  return 0;
}
0