結果

問題 No.2094 Symmetry
ユーザー nyyanyya
提出日時 2022-10-07 22:22:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 124 ms / 2,000 ms
コード長 1,225 bytes
コンパイル時間 4,120 ms
コンパイル使用メモリ 233,440 KB
実行使用メモリ 9,584 KB
最終ジャッジ日時 2023-09-03 13:23:30
合計ジャッジ時間 8,965 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 AC 123 ms
9,488 KB
testcase_10 AC 122 ms
9,500 KB
testcase_11 AC 121 ms
9,428 KB
testcase_12 AC 121 ms
9,508 KB
testcase_13 AC 121 ms
9,504 KB
testcase_14 AC 123 ms
9,428 KB
testcase_15 AC 121 ms
9,428 KB
testcase_16 AC 120 ms
9,428 KB
testcase_17 AC 121 ms
9,500 KB
testcase_18 AC 119 ms
9,468 KB
testcase_19 AC 119 ms
9,424 KB
testcase_20 AC 120 ms
9,508 KB
testcase_21 AC 121 ms
9,504 KB
testcase_22 AC 120 ms
9,452 KB
testcase_23 AC 121 ms
9,580 KB
testcase_24 AC 124 ms
9,452 KB
testcase_25 AC 123 ms
9,512 KB
testcase_26 AC 121 ms
9,512 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 103 ms
9,580 KB
testcase_29 AC 1 ms
4,384 KB
testcase_30 AC 109 ms
9,472 KB
testcase_31 AC 103 ms
9,580 KB
testcase_32 AC 108 ms
9,580 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 78 ms
9,436 KB
testcase_35 AC 64 ms
9,568 KB
testcase_36 AC 61 ms
9,584 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