結果

問題 No.2094 Symmetry
ユーザー ruthenruthen
提出日時 2022-10-07 23:13:52
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,791 bytes
コンパイル時間 4,742 ms
コンパイル使用メモリ 212,232 KB
実行使用メモリ 13,584 KB
最終ジャッジ日時 2023-09-03 15:25:36
合計ジャッジ時間 7,322 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
13,584 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#ifdef _RUTHEN
#include <debug.hpp>
#else
#define show(...) true
#endif

using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
template <class T> using V = vector<T>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    ll K;
    cin >> K;
    int N2 = N * 2;
    V<string> S(N2);
    rep(i, N2) cin >> S[i];
    V<V<ll>> C(N2, V<ll>(N2));
    rep(i, N2) rep(j, N2) cin >> C[i][j];
    V<ll> B;
    rep(i, N2) rep(j, N2) B.push_back(C[i][j]);
    sort(B.rbegin(), B.rend());
    show(B);
    int cnt = 0;
    rep(i, N2) rep(j, N2) cnt += S[i][j] == '#';
    ll ans = accumulate(B.begin(), B.begin() + cnt, 0LL);
    show(ans);
    V<pair<int, ll>> D, E;
    V<V<ll>> G(3);
    rep(i, N2) {
        rep(j, N) {
            // #
            int c1 = 0, c2 = 0;
            if (S[i][j] == '.') c1++;
            if (S[i][N2 - 1 - j] == '.') c1++;
            // .
            if (S[i][j] == '#') c2--;
            if (S[i][N2 - 1 - j] == '#') c2--;
            G[c1].push_back(C[i][j] + C[i][N2 - 1 - j]);
        }
    }
    rep(i, 3) sort(G[i].rbegin(), G[i].rend());
    V<ll> cum(G[0].size() + 1);
    rep(i, G[0].size()) cum[i + 1] = cum[i] + G[0][i];
    ll s2 = 0;
    show(G, cum);
    rep(i, G[2].size() + 1) {
        ll s1 = 0;
        rep(j, G[1].size() + 1) {
            int c = 2 * i + j - ((int)G[1].size() - j);
            show(i, j, c, G[0].size() - c / 2);
            if (c % 2 == 0 and (int) G[0].size() - c / 2 >= 0 and c >= 0) {
                ans = max(ans, K + s1 + s2 + cum[(int)G[0].size() - c / 2]);
            }
            if (j < G[1].size()) s1 += G[1][j];
        }
        if (i < G[2].size()) s2 += G[2][i];
    }
    cout << ans << '\n';
    return 0;
}
0