結果
問題 | No.2320 Game World for PvP |
ユーザー |
![]() |
提出日時 | 2023-05-26 21:47:48 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 2,487 bytes |
コンパイル時間 | 3,547 ms |
コンパイル使用メモリ | 259,864 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-25 06:11:28 |
合計ジャッジ時間 | 4,599 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#if __INCLUDE_LEVEL__ == 0#include <bits/stdc++.h>using namespace std;#undef assert#define assert(expr) (expr) || (__builtin_unreachable(), 0)#include __BASE_FILE__namespace std::ranges::views {namespace {void solve() {int n, s, t;cin >> tie(n, s, t);vector<int> color(n);while (s--) {int i;cin >> i;--i;color[i] = 1;}while (t--) {int i;cin >> i;--i;color[i] = 2;}s = n;t = s + 1;atcoder::mf_graph<int64_t> g(t + 1);int64_t ans = 0;for (int i : iota(0, n)) {for (int j : iota(0, n)) {int c;cin >> c;if (i < j) {ans += c;if (color[i] && color[i] == color[j]) {continue;}g.add_edge(i, j, c);g.add_edge(j, i, c);}}}for (int i : iota(0, n)) {if (color[i] == 1) {g.add_edge(s, i, 1e18);} else if (color[i] == 2) {g.add_edge(i, t, 1e18);}}ans -= g.flow(s, t);cout << ans << '\n';}} // namespace} // namespace std::ranges::viewsusing views::solve;int main() {ios::sync_with_stdio(false);cin.tie(nullptr);solve();}#else // __INCLUDE_LEVEL__#include <atcoder/maxflow>namespace std {template <class T1, class T2>istream& operator>>(istream& is, pair<T1, T2>& p) {return is >> p.first >> p.second;}template <class... Ts>istream& operator>>(istream& is, tuple<Ts...>& t) {return apply([&is](auto&... xs) -> istream& { return (is >> ... >> xs); }, t);}template <class... Ts>istream& operator>>(istream& is, tuple<Ts&...>&& t) {return is >> t;}template <class R, enable_if_t<!is_convertible_v<R, string>>* = nullptr>auto operator>>(istream& is, R&& r) -> decltype(is >> *begin(r)) {for (auto&& e : r) {is >> e;}return is;}template <class T1, class T2>ostream& operator<<(ostream& os, const pair<T1, T2>& p) {return os << p.first << ' ' << p.second;}template <class... Ts>ostream& operator<<(ostream& os, const tuple<Ts...>& t) {auto f = [&os](const auto&... xs) -> ostream& {[[maybe_unused]] auto sep = "";((os << exchange(sep, " ") << xs), ...);return os;};return apply(f, t);}template <class R, enable_if_t<!is_convertible_v<R, string_view>>* = nullptr>auto operator<<(ostream& os, R&& r) -> decltype(os << *begin(r)) {auto sep = "";for (auto&& e : r) {os << exchange(sep, " ") << e;}return os;}} // namespace std#endif // __INCLUDE_LEVEL__