// https://trap.jp/post/2887/ // https://judge.yosupo.jp/submission/347372 #include #include #include 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 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(); vectorS(H); rep(i,0,H)rep(j,0,W){ unsigned x=fin.nextNum(); S[i]+=x; cerr<<"OK"<