結果
| 問題 |
No.3306 Life is Easy?
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-10-08 00:12:06 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 226 ms / 2,000 ms |
| コード長 | 1,225 bytes |
| コンパイル時間 | 4,727 ms |
| コンパイル使用メモリ | 268,012 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-10-08 00:12:15 |
| 合計ジャッジ時間 | 7,572 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 35 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
#define rep(i, s, t) for (ll i = s; i < (ll)(t); i++)
#define all(x) begin(x), end(x)
template <class T> bool chmin(T& x, T y) {
return x > y ? (x = y, true) : false;
}
template <class T> bool chmax(T& x, T y) {
return x < y ? (x = y, true) : false;
}
struct io_setup {
io_setup() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout << fixed << setprecision(15);
}
} io_setup;
using mint = atcoder::modint998244353;
void solve() {
int n, m;
cin >> n >> m;
atcoder::mcf_graph<ll, ll> g(n * m + n * 2 + 2);
int st = n * m + n * 2, ed = st + 1;
vector<vector<int>> a(m, vector<int>(n));
rep(i, 0, n) rep(j, 0, m) cin >> a[j][i];
ll shf = 1e9;
rep(i, 0, n / 2) {
g.add_edge(st, n * m + i, 1, 0);
}
rep(i, n / 2, n) {
g.add_edge(n * m + n + i, ed, 1, 0);
}
rep(i, 0, m) {
rep(j, 0, n - 1) {
g.add_edge(i * n + j, i * n + j + 1, n, 0);
}
rep(j, 0, n) {
g.add_edge(n * m + j, i * n + j, 1, a[i][j]);
g.add_edge(i * n + j, n * m + n + j, 1, shf - a[i][j]);
}
}
auto [fl, cs] = g.flow(st, ed);
cout << fl * shf - cs << '\n';
}
int main() {
int t = 1;
// cin >> t;
while (t--) solve();
}