結果
| 問題 | No.3677 Global Checksum |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-09-05 01:05:31 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 6,517 bytes |
| 記録 | |
| コンパイル時間 | 2,094 ms |
| コンパイル使用メモリ | 352,956 KB |
| 実行使用メモリ | 7,720 KB |
| 最終ジャッジ日時 | 2026-09-05 01:05:40 |
| 合計ジャッジ時間 | 5,863 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 TLE * 1 -- * 7 |
ソースコード
#line 1 "main.cpp"
// #include "template/template.hpp"
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
#line 2 "library/util/fastio.hpp"
#line 4 "library/util/fastio.hpp"
namespace FastIO {
static constexpr unsigned int BUF_SIZE = 1 << 17;
struct InStream {
private:
using IS = InStream;
inline static unsigned int l = 0, r = 0;
inline static char buf[BUF_SIZE];
inline void load() {
memmove(buf, buf + l, r - l);
r = r - l + fread(buf + r - l, 1, BUF_SIZE - r + l, stdin);
l = 0;
if (r < BUF_SIZE) buf[r++] = '\n';
}
static bool isSpace(char c) { return c == ' ' || ('\t' <= c && c <= '\r'); }
public:
char seekChar() {
if (l >= r) load();
return buf[l];
}
void skipSpace() {
while (isSpace(seekChar())) l++;
}
template <class T>
T readUInteger() {
T x = 0;
skipSpace();
if (r - l < 100) load();
while (true) {
char c = buf[l];
if ('9' < c || c < '0') break;
x = x * 10 + (c - '0');
l++;
}
return x;
}
template <class T>
T readInteger() {
T x = 0;
skipSpace();
if (r - l < 100) load();
bool is_negative = seekChar() == '-';
if (is_negative) {
l++;
while (true) {
char c = buf[l];
if ('9' < c || c < '0') break;
x = x * 10 - (c - '0');
l++;
}
} else {
while (true) {
char c = buf[l];
if ('9' < c || c < '0') break;
x = x * 10 + (c - '0');
l++;
}
}
return x;
}
char readChar() {
skipSpace();
char c = seekChar();
l++;
return c;
}
std::string readString() {
std::string s;
skipSpace();
while (true) {
char c = seekChar();
if (isSpace(c) || c == '\0') break;
s.push_back(c);
l++;
}
return s;
}
IS& operator>>(unsigned int& x) { x = readUInteger<unsigned int>(); return *this; }
IS& operator>>(int& x) { x = readInteger<int>(); return *this; }
IS& operator>>(unsigned long long& x) { x = readUInteger<unsigned long long>(); return *this; }
IS& operator>>(long long& x) { x = readInteger<long long>(); return *this; }
IS& operator>>(char& c) { c = readChar(); return *this; }
IS& operator>>(std::string& s) { s = readString(); return *this; }
};
struct OutputTable {
char num[10000][5];
char tnum[10000][5];
constexpr OutputTable() : num(), tnum() {
for (int i = 0; i < 10000; i++) {
num[i][0] = '0' + i / 1000 % 10;
num[i][1] = '0' + i / 100 % 10;
num[i][2] = '0' + i / 10 % 10;
num[i][3] = '0' + i / 1 % 10;
num[i][4] = '\0';
int x = 0;
if (i >= 1000) tnum[i][x++] = '0' + i / 1000 % 10;
if (i >= 100) tnum[i][x++] = '0' + i / 100 % 10;
if (i >= 10) tnum[i][x++] = '0' + i / 10 % 10;
if (i >= 1) tnum[i][x++] = '0' + i / 1 % 10;
tnum[i][x++] = '\0';
}
}
} constexpr table;
struct OutStream {
private:
using OS = OutStream;
inline static unsigned int p = 0;
inline static char buf[BUF_SIZE];
static constexpr uint32_t P10(unsigned int d) { return d ? P10(d - 1) * 10 : 1; }
static constexpr uint64_t P10L(unsigned int d){ return d ? P10L(d - 1) * 10 : 1; }
template <class T, class U> static void Split(T& x, U& y, U z) noexcept { x = y / z; y -= x * z; }
void ensureOutput(unsigned int d) { if (p + d > BUF_SIZE) flush(); }
void writeNum(uint32_t x) {
memcpy(buf + p, table.num[x], 4);
p += 4;
}
void writeNumHead(uint32_t x) {
unsigned int n = x >= 1000 ? 4 : x >= 100 ? 3 : x >= 10 ? 2 : 1;
memcpy(buf + p, table.num[x] + 4 - n, n);
p += n;
}
void writeU32Unchecked(uint32_t x) {
unsigned int y = 0;
if (x >= P10(8)) {
Split(y, x, P10(8)); writeNumHead(y);
Split(y, x, P10(4)); writeNum(y);
writeNum(x);
} else if (x >= P10(4)) {
Split(y, x, P10(4)); writeNumHead(y);
writeNum(x);
} else if (x > 0) {
writeNumHead(x);
} else {
write('0');
}
}
void writeU64Unchecked(uint64_t x) {
unsigned int y = 0;
if (x >= P10L(16)) {
Split(y, x, P10L(16)); writeNumHead(y);
Split(y, x, P10L(12)); writeNum(y);
Split(y, x, P10L(8)); writeNum(y);
Split(y, x, P10L(4)); writeNum(y);
writeNum(x);
} else if (x >= P10L(12)) {
Split(y, x, P10L(12)); writeNumHead(y);
Split(y, x, P10L(8)); writeNum(y);
Split(y, x, P10L(4)); writeNum(y);
writeNum(x);
} else if (x >= P10L(8)) {
Split(y, x, P10L(8)); writeNumHead(y);
Split(y, x, P10L(4)); writeNum(y);
writeNum(x);
} else if (x >= P10L(4)) {
Split(y, x, P10L(4)); writeNumHead(y);
writeNum(x);
} else if (x > 0) {
writeNumHead(x);
} else {
write('0');
}
}
public:
~OutStream(){ flush(); }
void flush() {
fwrite(buf, 1, p, stdout);
p = 0;
}
void write(const char c) {
if (p == BUF_SIZE) flush();
buf[p++] = c;
}
void write(const char* s) { while (*s) write(*(s++)); }
void write(const std::string& s) { for (char c : s) write(c); }
void writeU32(uint32_t x) {
ensureOutput(10);
writeU32Unchecked(x);
}
void writeI32(int32_t x) {
ensureOutput(11);
if (x < 0) { write('-'); writeU32Unchecked(uint32_t(0) - static_cast<uint32_t>(x)); }
else writeU32Unchecked((uint32_t)x);
}
void writeU64(uint64_t x) {
ensureOutput(20);
writeU64Unchecked(x);
}
void writeI64(int64_t x) {
ensureOutput(21);
if (x < 0) { write('-'); writeU64Unchecked(uint64_t(0) - static_cast<uint64_t>(x)); }
else writeU64Unchecked((uint64_t)x);
}
OS& operator<<(unsigned int x) { writeU32(x); return *this; }
OS& operator<<(int x) { writeI32(x); return *this; }
OS& operator<<(unsigned long long x) { writeU64(x); return *this; }
OS& operator<<(long long x) { writeI64(x); return *this; }
OS& operator<<(const std::string& s) { write(s); return *this; }
OS& operator<<(const char* s) { write(s); return *this; }
OS& operator<<(char c) { write(c); return *this; }
};
}; // namespace FastIO
#line 8 "main.cpp"
FastIO::InStream is;
FastIO::OutStream os;
void solve() {
int H = is.readInteger<int>();
int W = is.readInteger<int>();
uint T = 0;
vector<uint> C(H);
for (int i = 0; i < H; i++) {
uint s = 0;
for (int j = 0; j < W; j++) s += is.readUInteger<uint>();
C[i] = s;
T += s;
}
for (auto& v : C) os.writeU32(v + T), os.write('\n');
}
int main() {
int T = 1;
// in(T);
while (T--) solve();
}