結果

問題 No.2094 Symmetry
ユーザー ruthenruthen
提出日時 2022-10-07 23:43:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 65 ms / 2,000 ms
コード長 1,033 bytes
コンパイル時間 2,482 ms
コンパイル使用メモリ 211,584 KB
実行使用メモリ 9,288 KB
最終ジャッジ日時 2023-09-03 16:23:29
合計ジャッジ時間 5,867 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 65 ms
9,216 KB
testcase_10 AC 61 ms
9,280 KB
testcase_11 AC 63 ms
9,220 KB
testcase_12 AC 61 ms
9,216 KB
testcase_13 AC 52 ms
7,396 KB
testcase_14 AC 62 ms
9,204 KB
testcase_15 AC 61 ms
9,224 KB
testcase_16 AC 62 ms
9,232 KB
testcase_17 AC 51 ms
7,408 KB
testcase_18 AC 53 ms
7,380 KB
testcase_19 AC 63 ms
9,276 KB
testcase_20 AC 62 ms
9,220 KB
testcase_21 AC 62 ms
9,240 KB
testcase_22 AC 62 ms
9,220 KB
testcase_23 AC 52 ms
7,460 KB
testcase_24 AC 53 ms
7,368 KB
testcase_25 AC 61 ms
9,244 KB
testcase_26 AC 62 ms
9,284 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 40 ms
9,220 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 42 ms
9,288 KB
testcase_31 AC 40 ms
9,280 KB
testcase_32 AC 43 ms
9,268 KB
testcase_33 AC 1 ms
4,376 KB
testcase_34 AC 35 ms
9,280 KB
testcase_35 AC 30 ms
9,276 KB
testcase_36 AC 31 ms
7,392 KB
権限があれば一括ダウンロードができます

ソースコード

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];
    int cnt = 0;
    rep(i, N2) rep(j, N2) cnt += S[i][j] == '#';
    V<ll> B;
    rep(i, N2) rep(j, N2) B.push_back(C[i][j]);
    sort(B.rbegin(), B.rend());
    ll ans = accumulate(B.begin(), B.begin() + cnt, 0LL);
    show(ans);
    if (cnt % 2 != 0) {
        cout << ans << '\n';
        return 0;
    }
    // symmetry
    V<ll> D;
    rep(i, N2) rep(j, N) D.push_back(C[i][j] + C[i][N2 - 1 - j]);
    sort(D.rbegin(), D.rend());
    ans = max(ans, K + accumulate(D.begin(), D.begin() + cnt / 2, 0LL));
    cout << ans << '\n';
    return 0;
}
0