結果

問題 No.2094 Symmetry
ユーザー shkiiii_shkiiii_
提出日時 2022-10-07 22:36:38
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 140 ms / 2,000 ms
コード長 1,019 bytes
コンパイル時間 1,640 ms
コンパイル使用メモリ 174,396 KB
実行使用メモリ 9,668 KB
最終ジャッジ日時 2023-09-03 13:57:29
合計ジャッジ時間 6,703 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 138 ms
9,624 KB
testcase_10 AC 138 ms
9,464 KB
testcase_11 AC 138 ms
9,384 KB
testcase_12 AC 138 ms
9,360 KB
testcase_13 AC 125 ms
7,676 KB
testcase_14 AC 139 ms
9,416 KB
testcase_15 AC 139 ms
9,668 KB
testcase_16 AC 140 ms
9,436 KB
testcase_17 AC 125 ms
7,616 KB
testcase_18 AC 125 ms
7,564 KB
testcase_19 AC 139 ms
9,420 KB
testcase_20 AC 140 ms
9,372 KB
testcase_21 AC 139 ms
9,364 KB
testcase_22 AC 138 ms
9,492 KB
testcase_23 AC 126 ms
7,516 KB
testcase_24 AC 126 ms
7,568 KB
testcase_25 AC 139 ms
9,484 KB
testcase_26 AC 139 ms
9,412 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 117 ms
9,416 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 122 ms
9,528 KB
testcase_31 AC 116 ms
9,464 KB
testcase_32 AC 123 ms
9,440 KB
testcase_33 AC 1 ms
4,380 KB
testcase_34 AC 87 ms
9,372 KB
testcase_35 AC 71 ms
9,444 KB
testcase_36 AC 65 ms
7,568 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
// #include<atcoder/all>
// #include<boost/multiprecision/cpp_int.hpp>

using namespace std;
// using namespace atcoder;
// using bint = boost::multiprecision::cpp_int;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007
// #define MOD 998244353


int main(){
  
  ll n,K;
  cin >> n >> K;
  vector<string> s(2*n);
  rep(i,2*n)cin >> s[i];
  vector<vector<ll>> c(2*n,vector<ll>(2*n));
  vector<ll> v(4*n*n);
  rep(i,2*n)rep(j,2*n)cin >> c[i][j],v[i*2*n + j] = c[i][j];
  int cnt = 0;
  rep(i,2*n)rep(j,2*n)cnt += (s[i][j] == '#');
  ll res = 0;
  if(cnt%2 == 0){
    vector<ll> g(4*n*n,-(1ll << 60));
    rep(i,2*n)rep(j,n)g[i*2*n + j] = c[i][j] + c[i][2*n-j-1];
    sort(ALL(g),greater<ll>());
    rep(i,cnt/2)res += g[i];
    res += K;
  }
  sort(ALL(v),greater<ll>());
  ll ans = 0;
  rep(i,cnt)ans += v[i];
  cout << max(res,ans)  << "\n";


  

  return 0;
}
0