結果

問題 No.2094 Symmetry
ユーザー nyyanyya
提出日時 2022-10-07 22:22:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 144 ms / 2,000 ms
コード長 1,225 bytes
コンパイル時間 3,821 ms
コンパイル使用メモリ 235,344 KB
実行使用メモリ 9,664 KB
最終ジャッジ日時 2023-09-03 13:23:40
合計ジャッジ時間 9,242 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 139 ms
9,420 KB
testcase_10 AC 139 ms
9,484 KB
testcase_11 AC 139 ms
9,416 KB
testcase_12 AC 138 ms
9,484 KB
testcase_13 AC 139 ms
9,448 KB
testcase_14 AC 139 ms
9,400 KB
testcase_15 AC 139 ms
9,444 KB
testcase_16 AC 139 ms
9,424 KB
testcase_17 AC 139 ms
9,492 KB
testcase_18 AC 140 ms
9,428 KB
testcase_19 AC 140 ms
9,428 KB
testcase_20 AC 139 ms
9,452 KB
testcase_21 AC 139 ms
9,420 KB
testcase_22 AC 144 ms
9,408 KB
testcase_23 AC 138 ms
9,548 KB
testcase_24 AC 143 ms
9,428 KB
testcase_25 AC 140 ms
9,488 KB
testcase_26 AC 138 ms
9,416 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 117 ms
9,528 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 124 ms
9,504 KB
testcase_31 AC 119 ms
9,664 KB
testcase_32 AC 125 ms
9,460 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 88 ms
9,428 KB
testcase_35 AC 73 ms
9,432 KB
testcase_36 AC 70 ms
9,444 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
//using mint = modint;
using mint = modint998244353;
using P = pair<int, int>;

const ll INF=1LL<<60, dx[]={0,1,0,-1},dy[]={1,0,-1,0};
bool chmin(ll& a,ll b){if(a>b){a=b; return 1;} return 0;}
bool chmax(ll& a,ll b){if(a<b){a=b; return 1;} return 0;}

int main(){

    int n;
    ll k;
    cin >> n >> k;

    int cnt=0;
    vector<string> s(2*n);
    rep(i,2*n) cin >> s[i];

    rep(i,2*n)rep(j,2*n) if(s[i][j]=='#')cnt++;

    vector<ll> c_1d(4*n*n),c_sum_1d(2*n*n);
    vector<vector<ll>> c(2*n,vector<ll> (2*n));
    vector<vector<ll>> c_sum(2*n,vector<ll> (n));

    rep(i,2*n)rep(j,2*n) cin >> c[i][j];
    rep(i,2*n)rep(j,2*n) c_1d[i*2*n+j]=c[i][j];
    rep(i,2*n)rep(j,n) c_sum[i][j]=c[i][j]+c[i][2*n-1-j];
    rep(i,2*n)rep(j,n) c_sum_1d[i*n+j]=c_sum[i][j];

    sort(c_1d.begin(),c_1d.end());
    sort(c_sum_1d.begin(),c_sum_1d.end());
    
    ll ans=0; 
    rep(i,cnt) ans += c_1d[4*n*n-1-i];
    
    if(cnt%2==0) {
        ll tmp=k;
        rep(i,cnt/2) tmp += c_sum_1d[2*n*n-1-i];
        chmax(ans,tmp);
    }

    cout << ans << endl;
    return 0;
}
0