結果

問題 No.2094 Symmetry
ユーザー nystnyst
提出日時 2022-10-08 10:27:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 138 ms / 2,000 ms
コード長 1,143 bytes
コンパイル時間 1,078 ms
コンパイル使用メモリ 112,368 KB
実行使用メモリ 8,608 KB
最終ジャッジ日時 2023-09-04 10:48:59
合計ジャッジ時間 6,348 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 137 ms
8,332 KB
testcase_10 AC 138 ms
8,308 KB
testcase_11 AC 138 ms
8,536 KB
testcase_12 AC 138 ms
8,608 KB
testcase_13 AC 128 ms
7,740 KB
testcase_14 AC 138 ms
8,336 KB
testcase_15 AC 138 ms
8,404 KB
testcase_16 AC 138 ms
8,392 KB
testcase_17 AC 127 ms
7,544 KB
testcase_18 AC 127 ms
7,544 KB
testcase_19 AC 137 ms
8,396 KB
testcase_20 AC 138 ms
8,340 KB
testcase_21 AC 138 ms
8,336 KB
testcase_22 AC 137 ms
8,308 KB
testcase_23 AC 127 ms
7,512 KB
testcase_24 AC 128 ms
7,608 KB
testcase_25 AC 138 ms
8,352 KB
testcase_26 AC 138 ms
8,308 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 115 ms
8,340 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 124 ms
8,428 KB
testcase_31 AC 117 ms
8,404 KB
testcase_32 AC 124 ms
8,372 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 86 ms
8,348 KB
testcase_35 AC 71 ms
8,332 KB
testcase_36 AC 65 ms
7,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <map>
#include <cmath>
#include <bitset>
#include <string>
using namespace std;

int main(){
    int n;
    long long k;
    cin >> n >> k;
    vector<string> v(2*n);
    for(int i=0;i<2*n;i++) cin >> v[i];
    int b_count = 0;
    for(int i=0;i<2*n;i++) for(int j=0;j<2*n;j++) if(v[i][j]=='#') b_count++;
    //asymmetry
    vector c(2*n,vector(2*n,0LL));
    vector sc(2*n*2*n,0LL); 
    for(int i=0;i<2*n;i++) for(int j=0;j<2*n;j++) {
        cin >> c[i][j];
        sc[i*2*n+j] = c[i][j];
    }
    sort(sc.begin(),sc.end(),greater<long long>());
    long long ans = 0;
    for(int i=0;i<b_count;i++) ans+=sc[i];
    if(b_count%2!=0){
        cout << ans << endl;
        return 0;
    }
    //symmetry
    vector asc(2*n*n,0LL);
    for(int i=0;i<2*n;i++){
        for(int j=0;j<n;j++){
            asc[n*i+j] = c[i][j] + c[i][2*n-j-1];
        }
    }
    sort(asc.begin(),asc.end(),greater<long long>());

    long long score = 0;
    for(int i=0;i<b_count/2;i++){
        score+= asc[i];
    }
    score += k;
    cout << max(score,ans) << endl;

}
0