結果

問題 No.2094 Symmetry
ユーザー shkiiii_shkiiii_
提出日時 2022-10-07 22:30:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,328 bytes
コンパイル時間 1,876 ms
コンパイル使用メモリ 173,212 KB
実行使用メモリ 11,652 KB
最終ジャッジ日時 2023-09-03 13:41:30
合計ジャッジ時間 6,062 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
11,652 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
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>
// #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));
  rep(i,2*n)rep(j,2*n)cin >> c[i][j];
  int cnt = 0;
  rep(i,2*n)rep(j,2*n)cnt += (s[i][j] == '#');
  ll res = -(1ll << 50);
  {
    vector<ll> dp(cnt+1,-(1ll << 60));
    dp[0] = 0;
    rep(i,2*n){
      vector<ll> DP(cnt+1,-(1ll << 60));
      rep(j,n)rep(k,cnt+1){
        if(k+2 <= cnt)DP[k+2] = max(DP[k+2],dp[k] + c[i][j] + c[i][2*n-j-1]);
        DP[k] = max(DP[k],dp[k]);
      }
      swap(dp,DP);
    }
    res = dp[cnt] + K;
  }
  {
    vector<ll> dp(cnt+1,-(1ll << 60));
    dp[0] = 0;
    rep(i,2*n){
      vector<ll> DP(cnt+1,-(1ll << 60));
      rep(j,2*n)rep(k,cnt+1){
        if(k+1 <= cnt)DP[k+1] = max(DP[k+1],dp[k] + c[i][j]);
        DP[k] = max(DP[k],dp[k]);
      }
      swap(dp,DP);
    }
    res = max(res,dp[cnt]);
  }
  cout << res << "\n";

  

  return 0;
}
0