結果
| 問題 | No.3677 Global Checksum |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-09-05 01:41:52 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 17,171 bytes |
| 記録 | |
| コンパイル時間 | 6,192 ms |
| コンパイル使用メモリ | 533,904 KB |
| 実行使用メモリ | 86,540 KB |
| 最終ジャッジ日時 | 2026-09-05 01:42:04 |
| 合計ジャッジ時間 | 9,936 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 TLE * 1 -- * 7 |
ソースコード
// https://judge.yosupo.jp/submission/356599
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/hash_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
// #include <atcoder/all>
// using mint = atcoder::modint998244353;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
// const ll dy[] = {-1, -1, -1, 0, 0, 1, 1, 1};
// const ll dx[] = {-1, 0, 1, -1, 1, -1, 0, 1};
const ll dy[] = {-1, 0, 0, 1};
const ll dx[] = {0, -1, 1, 0};
template <class T, class T1, class T2> bool isrange(T target, T1 low, T2 high) { return low <= target && target < high; }
template <class T, class U> T min(const T &t, const U &u) { return t < u ? t : u; }
template <class T, class U> T max(const T &t, const U &u) { return t < u ? u : t; }
template <class T, class U> bool chmin(T &t, const U &u) { if (t > u) { t = u; return true; } return false; }
template <class T, class U> bool chmax(T &t, const U &u) { if (t < u) { t = u; return true; } return false; }
template<class K, class V> using hash_map = gp_hash_table<K, V>;
template<class K> using hash_set = gp_hash_table<K, null_type>;
// #include "titan_cpplib/others/io.cpp"
/// https://github.com/titan-23/Library_cpp/blob/main/titan_cpplib/others/io.cpp
#include <bits/stdc++.h>
#include <unistd.h>
using namespace std;
namespace titan23 {
// 参考: https://qiita.com/nojima/items/57b9d39d7d73362ac883
class Scanner {
private:
vector<char> buffer;
ssize_t n_written;
ssize_t n_read;
void do_read() {
ssize_t r = read(0, &buffer[0], buffer.size());
if (r < 0) throw runtime_error(strerror(errno));
n_written = r;
n_read = 0;
}
inline int next_char() {
++n_read;
if (n_read == n_written) { do_read(); }
return current_char();
}
inline int current_char() {
return (n_read == n_written) ? EOF : buffer[n_read];
}
public:
Scanner(): buffer(1<<20) { do_read(); }
int64_t read_int64() {
int64_t ret = 0, sgn = 1;
int ch = current_char();
while (isspace(ch)) { ch = next_char(); }
if (ch == '-') { sgn = -1; ch = next_char(); }
for (; isdigit(ch); ch = next_char())
ret = (ret * 10) + (ch - '0');
return sgn * ret;
}
char read_char() {
int ch = current_char();
while (isspace(ch)) {
ch = next_char();
}
next_char();
return ch;
}
string read_string() {
string ret;
int ch = current_char();
while (isspace(ch)) {
ch = next_char();
}
while (!isspace(ch) && ch != EOF) {
ret += ch;
ch = next_char();
}
return ret;
}
} scanner;
} // namespace titan23
int64_t read_int64() { return titan23::scanner.read_int64(); }
// #include "titan_cpplib/others/print.cpp"
// #include "titan_cpplib/ahc/timer.cpp"
// https://judge.yosupo.jp/problem/many_aplusb
#include <bits/stdc++.h>
namespace debug {
} // namespace debug
#ifdef LOCAL
#define CHECK(expr) assert(expr)
#else
#define CHECK(expr) void(0)
#endif
#ifndef __SIZEOF_INT128__
#error "This library requires compiler support for __int128."
#endif
namespace internal {
template <typename T, typename U>
concept same_as = std::same_as<std::remove_cvref_t<T>, std::remove_cvref_t<U>>;
template <typename T>
concept basic_signed_integral =
std::signed_integral<std::remove_cvref_t<T>> && !same_as<T, char>;
template <typename T>
concept basic_unsigned_integral =
std::unsigned_integral<std::remove_cvref_t<T>> && !same_as<T, bool>;
template <typename T>
concept basic_integral = basic_signed_integral<T> || basic_unsigned_integral<T>;
template <typename T>
concept signed_integral = basic_signed_integral<T> || same_as<T, __int128_t>;
template <typename T>
concept unsigned_integral =
basic_unsigned_integral<T> || same_as<T, __uint128_t>;
template <typename T>
concept integral = signed_integral<T> || unsigned_integral<T>;
template <typename T>
struct make_unsigned : std::make_unsigned<std::remove_cvref_t<T>> {};
template <typename T>
requires(same_as<T, __int128_t> || same_as<T, __uint128_t>)
struct make_unsigned<T> {
using type = __uint128_t;
};
template <typename T>
using make_unsigned_t = typename make_unsigned<T>::type;
} // namespace internal
#ifdef __unix__
#ifndef DISABLE_MMAP
#define ENABLE_MMAP
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>
#endif
#endif
namespace fast_io {
template <int BufSize = 1 << 20>
struct FastInput {
FILE* file;
char* buf;
char* cur;
char* end;
size_t map_size;
explicit FastInput(FILE* _file = stdin) : file(_file) {
#ifdef ENABLE_MMAP
struct stat st;
int fd = fileno(file);
fstat(fd, &st);
map_size = st.st_size;
buf = cur = static_cast<char*>(
mmap(nullptr, map_size, PROT_READ, MAP_PRIVATE, fd, 0));
end = cur + map_size;
#else
cur = buf = new char[BufSize + 64];
end = buf + fread(buf, 1, BufSize, file);
memset(const_cast<char*>(end), 0, 64);
#endif
}
#ifdef ENABLE_MMAP
~FastInput() { munmap(buf, map_size); }
#else
~FastInput() { delete[] buf; }
#endif
void ensure() {
#ifndef ENABLE_MMAP
int rem = end - cur;
if (rem >= 40) [[likely]] return;
if (rem > 0 && cur != buf) memmove(buf, cur, rem);
cur = buf;
end = buf + rem + fread(buf + rem, 1, BufSize - rem, file);
memset(const_cast<char*>(end), 0, 64);
#endif
}
void skip_space() {
ensure();
while (*cur < 33) [[unlikely]] {
++cur;
ensure();
}
}
template <typename T>
requires(internal::same_as<T, bool>)
T read() {
ensure();
CHECK(*cur == '0' || *cur == '1');
T x = *cur & 1;
cur += 2;
return x;
}
template <internal::unsigned_integral T>
T read_small() {
ensure();
CHECK(*cur >= '0' && *cur <= '9');
T x = *cur++ & 15;
uint32_t v;
memcpy(&v, cur, 4);
v ^= 0x30303030;
if (all_digits(v)) {
v = (v * 10 + (v >> 8)) & 0xff00ff;
v = (v * 100 + (v >> 16)) & 0xffff;
x = x * 10000 + v, cur += 4;
}
for (; *cur >= 48; ++cur) {
x = x * 10 + *cur - 48;
}
++cur;
return x;
}
template <internal::signed_integral T>
T read_small() {
using U = internal::make_unsigned_t<T>;
bool neg = (*cur == '-');
cur += neg;
U v = read_small<U>();
return static_cast<T>(neg ? -v : v);
}
template <internal::unsigned_integral T>
requires(sizeof(T) < 8)
T read() {
ensure();
CHECK(*cur >= '0' && *cur <= '9');
T x = *cur++ & 15;
uint64_t v;
memcpy(&v, cur, 8);
v ^= 0x3030303030303030ull;
if (all_digits(v)) {
v = (v * 10 + (v >> 8)) & 0xff00ff00ff00ffull;
v = (v * 100 + (v >> 16)) & 0xffff0000ffffull;
v = (v * 10000 + (v >> 32)) & 0xffffffffull;
x = x * 100000000 + v, cur += 8;
}
for (; *cur >= 48; ++cur) {
x = x * 10 + *cur - 48;
}
++cur;
return x;
}
template <internal::unsigned_integral T>
requires(sizeof(T) == 8)
T read() {
ensure();
CHECK(*cur >= '0' && *cur <= '9');
union {
char ch[16];
uint64_t v[2];
};
memcpy(ch, cur, 16);
uint64_t a = v[0] ^ 0x3030303030303030ull;
uint64_t b = v[1] ^ 0x3030303030303030ull;
T x = 0;
if (all_digits(a)) {
x = a = parse(a), cur += 8;
if (all_digits(b)) {
x = a * 100000000 + parse(b), cur += 8;
if (~LUT[*reinterpret_cast<uint16_t*>(cur)]) {
x = x * 100 + LUT[*reinterpret_cast<uint16_t*>(cur)];
cur += 2;
}
}
}
for (; *cur >= 48; ++cur) {
x = x * 10 + (*cur & 15);
}
++cur;
return x;
}
template <internal::unsigned_integral T>
requires(sizeof(T) > 8)
T read() {
ensure();
CHECK(*cur >= '0' && *cur <= '9');
T x = 0;
for (int i = 0; i < 4; ++i) {
uint64_t v;
memcpy(&v, cur, 8);
v ^= 0x3030303030303030ull;
if (!all_digits(v)) break;
v = (v * 10 + (v >> 8)) & 0xff00ff00ff00ffull;
v = (v * 100 + (v >> 16)) & 0xffff0000ffffull;
v = (v * 10000 + (v >> 32)) & 0xffffffffull;
if (i != 0) x *= 100000000;
x += v, cur += 8;
}
uint32_t v;
memcpy(&v, cur, 4);
v ^= 0x30303030;
uint32_t val = 0, pow = 1;
if (all_digits(v)) {
v = (v * 10 + (v >> 8)) & 0xff00ff;
v = (v * 100 + (v >> 16)) & 0xffff;
val = v, pow = 10000, cur += 4;
}
for (; *cur >= 48; ++cur) {
val = val * 10 + *cur - 48, pow *= 10;
}
x = x * pow + val;
++cur;
return x;
}
template <internal::signed_integral T>
T read() {
using U = internal::make_unsigned_t<T>;
bool neg = (*cur == '-');
cur += neg;
U v = read<U>();
return static_cast<T>(neg ? -v : v);
}
template <typename T>
requires(internal::same_as<T, char>)
T read() {
ensure();
T x = *cur;
cur += 2;
return x;
}
template <typename T>
requires(internal::same_as<T, std::string>)
T read() {
ensure();
CHECK(*cur > 32);
#ifdef ENABLE_MMAP
char* first = cur;
while (*cur > 32) ++cur;
std::string s(first, cur);
++cur;
return s;
#else
std::string s;
while (true) {
char* last = cur;
while (last < end && *last > 32) ++last;
if (last < end) {
s.append(cur, last);
cur = last + 1;
return s;
} else {
s.append(cur, last);
cur = end;
ensure();
}
}
#endif
}
template <typename T>
FastInput& operator>>(T& x) {
skip_space();
x = read<T>();
return *this;
}
FastInput& operator>>(char* s) {
skip_space();
while (*cur > 32) {
*s++ = *cur++;
ensure();
}
*s = 0, ++cur;
return *this;
}
private:
static constexpr auto LUT = [] {
std::array<uint32_t, 1 << 16> a;
std::fill(a.begin(), a.end(), -1);
for (int i = 48; i < 58; ++i) {
for (int j = 48; j < 58; ++j) {
a[i | j << 8] = (i - 48) * 10 + (j - 48);
}
}
return a;
}();
constexpr bool all_digits(uint32_t v) {
return !(v & 0xf0f0f0f0);
}
constexpr bool all_digits(uint64_t v) {
return !(v & 0xf0f0f0f0f0f0f0f0ull);
}
constexpr uint32_t parse(uint32_t v) {
v = (v * 10 + (v >> 8)) & 0xff00ff;
v = (v * 100 + (v >> 16)) & 0xffff;
return v;
}
constexpr uint64_t parse(uint64_t v) {
v = (v * 10 + (v >> 8)) & 0xff00ff00ff00ffull;
v = (v * 100 + (v >> 16)) & 0xffff0000ffffull;
v = (v * 10000 + (v >> 32)) & 0xffffffffull;
return v;
}
};
struct EndLine {
} endl;
template <uint32_t BufSize = 1 << 19>
struct FastOutput {
FILE* file;
char* buf;
char* cur;
char* end;
explicit FastOutput(FILE* _file = stdout) : file(_file) {
cur = buf = new char[BufSize];
end = buf + BufSize;
}
template <int N = BufSize>
void flush() {
if (end - cur < N) [[unlikely]] {
fwrite(buf, 1, cur - buf, file);
cur = buf;
}
}
~FastOutput() {
flush();
delete[] buf;
}
template <typename T>
requires(sizeof(T) < 8)
void write(T x) {
if (x > 9999'9999) {
print<2>(x);
} else if (x > 9999) {
print<1>(x);
} else {
print<0>(x);
}
}
template <typename T>
requires(sizeof(T) == 8)
void write(T x) {
if (x > 9999'9999'9999'9999ull) {
print<4>(x);
} else if (x > 9999'9999'9999ull) {
print<3>(x);
} else if (x > 9999'9999) {
print<2>(x);
} else if (x > 9999) {
print<1>(static_cast<uint32_t>(x));
} else {
print<0>(static_cast<uint32_t>(x));
}
}
template <typename T>
requires(sizeof(T) > 8)
void write(T x) {
if (x < E19) {
write(static_cast<uint64_t>(x));
} else if (x < E38) {
auto high = x / E19;
auto low = x - high * E19;
write(static_cast<uint64_t>(high));
print_E19(static_cast<uint64_t>(low));
} else [[unlikely]] {
auto high = x / E38;
x -= high * E38;
auto mid = x / E19;
auto low = x - mid * E19;
write(static_cast<uint32_t>(high));
print_E19(static_cast<uint64_t>(mid));
print_E19(static_cast<uint64_t>(low));
}
}
template <internal::unsigned_integral T>
FastOutput& operator<<(T x) {
flush<std::numeric_limits<T>::digits10 + 1>();
write(x);
return *this;
}
template <internal::signed_integral T>
FastOutput& operator<<(T x) {
using U = internal::make_unsigned_t<T>;
flush<std::numeric_limits<T>::digits10 + 2>();
*cur = '-';
cur += (x < 0);
write(x < 0 ? -static_cast<U>(x) : static_cast<U>(x));
return *this;
}
FastOutput& operator<<(bool x) {
flush<1>();
*cur++ = x + '0';
return *this;
}
FastOutput& operator<<(char x) {
flush<1>();
*cur++ = x;
return *this;
}
FastOutput& operator<<(const char* s) {
uint32_t len = strlen(s);
if (len > BufSize) [[unlikely]] {
flush();
do {
fwrite(s, 1, BufSize, file);
s += BufSize;
len -= BufSize;
} while (len > BufSize);
}
if (end - cur < len) [[unlikely]] flush();
memcpy(cur, s, len);
cur += len;
return *this;
}
FastOutput& operator<<(char* s) {
return *this << const_cast<const char*>(s);
}
FastOutput& operator<<(const std::string& s) {
return *this << s.c_str();
}
FastOutput& operator<<(const EndLine& end_line) {
flush<1>();
*cur++ = '\n';
flush();
return *this;
}
private:
static constexpr auto LUT = [] {
std::array<std::array<char, 4>, 10000> a, b;
for (int i = 0; i < 10000; ++i) {
b[i][0] = '0' + i / 1000;
b[i][1] = '0' + i / 100 % 10;
b[i][2] = '0' + i / 10 % 10;
b[i][3] = '0' + i % 10;
int j = 0;
if (i >= 1000) a[i][j++] = b[i][0];
if (i >= 100) a[i][j++] = b[i][1];
if (i >= 10) a[i][j++] = b[i][2];
a[i][j] = b[i][3];
}
return std::make_pair(a, b);
}();
static constexpr auto E16 = 10'000'000'000'000'000ull;
static constexpr auto E19 = E16 * 1000;
static constexpr auto E38 = static_cast<__uint128_t>(E19) * E19;
template <bool head>
void print_unit(uint32_t x) {
if constexpr (head) {
memcpy(cur, &LUT.first[x], 4);
cur += 1 + (x > 9) + (x > 99) + (x > 999);
} else {
memcpy(cur, &LUT.second[x], 4);
cur += 4;
}
}
template <int N, bool head = true, typename T>
void print(T x) {
if constexpr (N == 0) {
print_unit<head>(x);
} else {
print<N - 1, head>(x / 10000);
print_unit<false>(x % 10000);
}
}
void print_E19(uint64_t x) {
auto high = static_cast<uint32_t>(x / E16);
auto low = x - high * E16;
memcpy(cur, &LUT.second[high][1], 3);
cur += 3;
print<3, false>(low);
}
};
template <uint32_t InputBufSize = 1 << 20, uint32_t OutputBufSize = 1 << 19>
struct FastIO {
FastInput<InputBufSize>* in;
FastOutput<OutputBufSize>* out;
FastIO() : in(nullptr), out(nullptr) {}
~FastIO() {
if (in != nullptr) delete in;
if (out != nullptr) {
out->flush();
delete out;
}
}
void init(FILE* input_file = stdin, FILE* output_file = stdout) {
in = new FastInput<InputBufSize>(input_file);
out = new FastOutput<OutputBufSize>(output_file);
}
void flush() { out->flush(); }
template <typename T>
FastIO& operator>>(T& x) {
*in >> x;
return *this;
}
template <typename T>
FastIO& operator<<(const T& x) {
*out << x;
return *this;
}
FastIO& operator<<(const EndLine& x) {
*out << x;
return *this;
}
};
} // namespace fast_io
using fast_io::FastIO;
using namespace std;
FastIO<1 << 21, 1 << 20> io;
// void solve_main() {
// int n;
// io >> n;
// while (n--) {
// io << io.in->read<uint64_t>() + io.in->read<uint64_t>() << '\n';
// }
// }
// int main() {
// #ifdef LOCAL
// assert(freopen("test.in", "r", stdin));
// assert(freopen("test.out", "w", stdout));
// #endif
// // cin.tie(nullptr)->sync_with_stdio(false);
// io.init();
// int T;
// // cin >> T;
// // io >> T;
// T = 1;
// while (T--) {
// solve_main();
// }
// return 0;
// }
void solve() {
const uint64_t msk = (1ull << 32)-1;
int h = io.in->read<uint32_t>(), w = io.in->read<uint32_t>();
vector<vector<uint32_t>> A(h, vector<uint32_t>(w));
rep(i, h) rep(j, w) A[i][j] = io.in->read<uint32_t>();
uint32_t T = 0;
rep(i, h) {
uint32_t s = 0;
rep(j, w) {
s += A[i][j];
s &= msk;
}
s &= msk;
T += s;
T &= msk;
A[i][0] = s;
}
rep(i, h) {
io << ((A[i][0]+T)&msk) << "\n";
}
}
int main() {
// ios::sync_with_stdio(false);
// cin.tie(0);
io.init();
cout << fixed << setprecision(15);
cerr << fixed << setprecision(15);
int t = 1;
// cin >> t;
for (int i = 0; i < t; ++i) {
solve();
}
return 0;
}