結果
| 問題 | No.3677 Global Checksum |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-09-04 23:17:44 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 12,898 bytes |
| 記録 | |
| コンパイル時間 | 2,915 ms |
| コンパイル使用メモリ | 380,276 KB |
| 実行使用メモリ | 23,040 KB |
| 最終ジャッジ日時 | 2026-09-04 23:17:51 |
| 合計ジャッジ時間 | 6,712 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge4_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 TLE * 1 -- * 7 |
コンパイルメッセージ
main.cpp: In constructor 'mylib::FastRead::FastRead(FILE*)':
main.cpp:282:31: warning: member 'mylib::FastRead::buf_' is used uninitialized [-Wuninitialized]
282 | : stream_(stream), begin_(buf_.data()), end_(begin_ + BUF_SIZE), ptr_(end_) { read(); }
| ^~~~
main.cpp: In constructor 'mylib::FastWrite::FastWrite(FILE*)':
main.cpp:415:31: warning: member 'mylib::FastWrite::buf_' is used uninitialized [-Wuninitialized]
415 | : stream_(stream), begin_(buf_.data()), end_(begin_ + BUF_SIZE), ptr_(begin_) {}
| ^~~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
// 数値型
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int,int>;
using Pll = pair<ll, ll>;
using Pli = pair<ll, int>;
using Pil = pair<int, ll>;
// vector関連
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
template<typename T>
using vc = vector<T>;
template<typename T>
using vvc = vector<vc<T>>;
template<typename T>
using vvvc = vector<vvc<T>>;
template<typename T>
using vvvvc = vector<vvvc<T>>;
// priority_queue
template<typename T>
using pq = priority_queue<T>;
template<typename T>
using pqg = priority_queue<T, vc<T>, greater<T>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = a; i < (int)(b); i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define MIN(vec) *min_element(vec)
#define MAX(vec) *max_element(vec)
#define next_perm(vec) next_permutation((vec).begin(), (vec).end())
#define UNIQUE(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define el "\n"
#define Yes cout << "Yes" << el
#define No cout << "No" << el
#define YES cout << "YES" << el
#define NO cout << "NO" << el
#define EPS 1e-8
#define Equal(a, b) (fabs((a)-(b)) < EPS)
#define dbg(x) cerr << #x << "=" << x << el
// 定数
const string abc = "abcdefghijklmnopqrstuvwxyz";
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
constexpr int INF = 1001001001;
constexpr ll LINF = 1001001001001001001ll;
constexpr int DX[] = {1, 0, -1, 0};
constexpr int DY[] = {0, 1, 0, -1};
constexpr int DX8[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int DY8[] = {0, 1, 0, -1, 1, -1, 1, -1};
template<typename T1, typename T2>
ostream &operator<< (ostream &os, pair<T1, T2> p) {
os << "{" << p.first << "," << p.second << "}";
return os;
}
template<typename T>
ostream &operator<< (ostream &os, vc<T> &vec) {
int sz = vec.size();
rep(i, sz){
os << vec[i] << (i==sz-1?"":" ");
}
return os;
}
template<typename T1, typename T2>
istream &operator>> (istream &is, pair<T1, T2> &p) {
is >> p.first >> p.second;
return is;
}
template<typename T>
istream &operator>> (istream &is, vc<T> &vec) {
int sz = vec.size();
rep(i, sz) { is >> vec[i]; }
return is;
}
/// @brief aとbの最大値をaに格納。更新があったかbool値を返す
/// @tparam T1
/// @tparam T2
/// @param a
/// @param b
/// @return bool
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b){
bool ret = a<b;
if(ret) a = b;
return ret;
}
/// @brief aとbの最小値をaに格納。更新があったかbool値を返す
/// @tparam T1
/// @tparam T2
/// @param a
/// @param b
/// @return bool
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b){
bool ret = a>b;
if(ret) {a = b;}
return ret;
}
inline void YesNo(bool flag){
if(flag) {Yes;}
else {No;}
return;
}
inline void YESNO(bool flag){
if(flag) {YES;}
else {NO;}
return;
}
inline bool outof(ll x, ll xlim){
return (x<0 || x>=xlim);
}
template<typename T>
inline T sqnorm(T x, T y){
return x*x+y*y;
}
/// @brief char->int
/// @param c
/// @return int
inline int ctoi(char c){
return c-'0';
}
/// @brief xを素因数分解
/// @param x
/// @return vector<Pli>, 素因数の昇順に {p, cnt}
vector<Pli> prime_fact(ll x){
vector<Pli> ret;
for(ll i=2; i*i<=x; i++){
if(x%i == 0){
ret.emplace_back(i, 0);
while(x%i == 0){
ret.back().second++;
x /= i;
}
}
}
if(x != 1) ret.emplace_back(x, 1);
return ret;
}
/// @brief xの約数列挙
/// @param x
/// @return vll, 約数の昇順
vll divisor_enum(ll x){
vector<ll> ret;
for(ll i=1; i*i<=x; i++){
if(x%i == 0){
ret.push_back(x/i);
ret.push_back(i);
}
}
sort(all(ret));
UNIQUE(ret);
return ret;
}
/// @brief 繰り返し二乗法。
/// @tparam T
/// @param x
/// @param k
/// @param op
/// @param e
/// @return
template<typename T>
T pow_t(T x, ll k, T (*op)(T, T), T (*e)()){
T ret = e();
while(k){
if(k&1) ret = op(ret, x);
x = op(x, x);
k >>= 1;
}
return ret;
}
ll powll(ll x, ll k){
return pow_t<ll>(x, k, [](ll a, ll b) -> ll{return a*b;}, []() -> ll{return 1;});
}
inline int pop_cnt(ll x) { return __builtin_popcountll(x); }
inline int top_bit(ll x) { return (x==0?-1:63-__builtin_clzll(x));}
void main2();
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
main2();
}
#include<cstdio>
using namespace std;
namespace mylib {
static constexpr int BUF_SIZE = 1 << 17;
struct FastRead {
private:
FILE *stream_;
array<char, BUF_SIZE> buf_;
char *begin_;
char *end_;
char *ptr_;
// reader
void skip_space() {
while (*ptr_ <= ' ') ++ptr_;
}
template<int N = 0> void read() {
if (const auto n = end_ - ptr_; n <= N) {
ignore = fread(copy_n(ptr_, n, begin_), 1, BUF_SIZE - n, stream_);
ptr_ = begin_;
}
}
// parser
template<unsigned_integral T> void parse(T &x) {
common_type_t<T, uint64_t> x2 = 0;
while (true) {
uint64_t v;
memcpy(&v, ptr_, 8);
if ((v -= 0x3030303030303030) & 0x8080808080808080) break;
v = (v * 10 + (v >> 8)) & 0xff00ff00ff00ff;
v = (v * 100 + (v >> 16)) & 0xffff0000ffff;
v = (v * 10000 + (v >> 32)) & 0xffffffff;
x2 = 100000000 * x2 + v;
ptr_ += 8;
}
while (true) {
uint32_t v;
memcpy(&v, ptr_, 4);
if ((v -= 0x30303030) & 0x80808080) break;
v = (v * 10 + (v >> 8)) & 0xff00ff;
v = (v * 100 + (v >> 16)) & 0xffff;
x2 = 10000 * x2 + v;
ptr_ += 4;
break;
}
while (true) {
uint16_t v;
memcpy(&v, ptr_, 2);
if ((v -= 0x3030) & 0x8080) break;
v = (v * 10 + (v >> 8)) & 0xff;
x2 = 100 * x2 + v;
ptr_ += 2;
break;
}
if (' ' < *ptr_) {
x2 *= 10;
x2 += *ptr_++ - '0';
}
++ptr_;
x = static_cast<T>(x2);
}
public:
// constructor
FastRead() : FastRead(stdin) {}
explicit FastRead(const filesystem::path& p) : FastRead(fopen(p.c_str(), "r")) {}
explicit FastRead(FILE *stream)
: stream_(stream), begin_(buf_.data()), end_(begin_ + BUF_SIZE), ptr_(end_) { read(); }
~FastRead() { if (stream_ != stdin) fclose(stream_); }
FastRead(const FastRead&) = delete;
FastRead &operator = (const FastRead&) = delete;
// operators
template<unsigned_integral T> void operator () (T &x) {
skip_space();
read<64>();
parse(x);
}
template<signed_integral T> void operator () (T &x) {
skip_space();
read<64>();
make_unsigned_t<T> u;
if (*ptr_ == '-') {
++ptr_;
parse(u);
u = -u;
} else {
parse(u);
}
x = u;
}
void operator () (char &x) {
skip_space();
read<64>();
x = *ptr_;
++ptr_;
}
void operator () (string &x) {
x = "";
skip_space();
read<64>();
while (*ptr_ > ' ' && *ptr_ != '\0') {
x.push_back(*ptr_);
++ptr_;
}
++ptr_;
}
template<class... Ts> requires(sizeof...(Ts) != 1) void operator () (Ts&... xs) {
((*this)(xs), ...);
}
template<class T> FastRead& operator >> (T &x) { (*this)(x); return *this; }
};
class FastWrite {
private:
FILE *stream_;
array<char, BUF_SIZE> buf_;
char *begin_;
char *end_;
char *ptr_;
// preparation
template <class T> static constexpr int DIGITS = numeric_limits<T>::digits10 + 1;
template <class T> static constexpr auto POW10 = [] {
array<T, DIGITS<T>> ret;
ret[0] = 1;
for (int i = 1; i < DIGITS<T>; ++i) {
ret[i] = 10 * ret[i - 1];
}
return ret;
} ();
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;
} ();
// flush
template<int N = BUF_SIZE> void flush() {
if (end_ - ptr_ <= N) {
fwrite(begin_, 1, ptr_ - begin_, stream_);
ptr_ = begin_;
}
}
// writer
template<int N = 4> void le4(uint64_t x) {
if constexpr (1 < N) {
if (x < POW10<uint64_t>[N - 1]) {
le4<N - 1>(x);
return;
}
}
ptr_ = copy_n(&LUT[x * 4 + (4 - N)], N, ptr_);
}
template<int N> void w4(uint64_t x) {
if constexpr (0 < N) {
ptr_ = copy_n(&LUT[x / POW10<uint64_t>[N - 4] * 4], 4, ptr_);
w4<N - 4>(x % POW10<uint64_t>[N - 4]);
}
}
template<int N> void write(uint64_t x) {
if constexpr (N < DIGITS<uint64_t>) {
if (POW10<uint64_t>[N] <= x) {
write<N + 4>(x);
return;
}
}
le4(x / POW10<uint64_t>[N - 4]);
w4<N - 4>(x % POW10<uint64_t>[N - 4]);
}
void write(unsigned_integral auto x) {
write<4>(x);
}
void write(__uint128_t x) {
if (x < POW10<__uint128_t>[16]) {
write(static_cast<uint64_t>(x));
} else if (x < POW10<__uint128_t>[32]) {
write(static_cast<uint64_t>(x / POW10<__uint128_t>[16]));
w4<16>(static_cast<uint64_t>(x % POW10<__uint128_t>[16]));
} else {
write(static_cast<uint64_t>(x / POW10<__uint128_t>[32]));
x %= POW10<__uint128_t>[32];
w4<16>(static_cast<uint64_t>(x / POW10<__uint128_t>[16]));
w4<16>(static_cast<uint64_t>(x % POW10<__uint128_t>[16]));
}
}
public:
// constructor
FastWrite() : FastWrite(stdout) {}
explicit FastWrite(const filesystem::path& p) : FastWrite(fopen(p.c_str(), "w")) {}
explicit FastWrite(FILE* stream)
: stream_(stream), begin_(buf_.data()), end_(begin_ + BUF_SIZE), ptr_(begin_) {}
~FastWrite() {
flush();
if (stream_ != stdout) { fclose(stream_); }
}
FastWrite(const FastWrite&) = delete;
FastWrite& operator = (const FastWrite&) = delete;
// operators
template<unsigned_integral T> void operator () (T x) {
flush<DIGITS<T>>();
write(x);
}
template<signed_integral T> void operator () (T x) {
flush<1 + DIGITS<T>>();
using U = make_unsigned_t<T>;
const U u = x;
if (x < 0) {
*ptr_++ = '-';
write(static_cast<U>(-u));
} else {
write(u);
}
}
void operator () (char c) {
flush<1>();
*ptr_++ = c;
}
void operator () (string_view s) {
while (!s.empty()) {
flush<0>();
const auto n = min(ssize(s), end_ - ptr_);
if (n == BUF_SIZE) {
fwrite(s.data(), 1, BUF_SIZE, stream_);
} else {
ptr_ = copy_n(s.data(), n, ptr_);
}
s.remove_prefix(n);
}
flush<0>();
}
template <char End = '\n', char Sep = ' ', class T, class... Ts>
void ln(T&& x, Ts&&... xs) {
(*this)(forward<T>(x));
if constexpr (sizeof...(Ts) == 0) {
*ptr_++ = End;
} else {
*ptr_++ = Sep;
ln<End, Sep>(forward<Ts>(xs)...);
}
}
template<class T> FastWrite& operator << (T x) { (*this)(x); return *this; }
};
mylib::FastRead cin;
mylib::FastWrite cout;
} // namespace mylib
// https://judge.yosupo.jp/submission/296458
using uint = unsigned int;
void main2(){
using mylib::cin;
using mylib::cout;
int h, w;
cin >> h >> w;
vc<uint> a((h+1)*(w+1), 0);
auto get_idx = [&](int i, int j) -> int {
return i*(w+1) + j;
};
rep(i, h) {
rep(j, w) cin >> a[get_idx(i, j)];
}
rep(i, h) rep(j, w) a[get_idx(i, w)] += a[get_idx(i, j)];
rep(i, h) a[get_idx(h, w)] += a[get_idx(i, w)];
rep(i, h) {
uint x = a[get_idx(i, w)] + a[get_idx(h, w)];
cout << x << el;
}
return;
}