結果

問題 No.2094 Symmetry
ユーザー AFLeartLey0103AFLeartLey0103
提出日時 2022-10-07 22:04:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,485 bytes
コンパイル時間 1,697 ms
コンパイル使用メモリ 170,360 KB
実行使用メモリ 11,200 KB
最終ジャッジ日時 2023-09-03 12:38:59
合計ジャッジ時間 10,601 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,768 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 1 ms
4,384 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,384 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 WA -
testcase_19 TLE -
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>
using namespace std;
#define int long long
const int maxn = 255;
int n,k;
int cnt;
bitset<maxn> vis[maxn];
int gr[maxn][maxn];
class node{
    public:
    int x,y,val;
    node(){}
    node(int _x,int _y,int _val):x(_x),y(_y),val(_val){}
    friend bool operator<(node a,node b){return a.val < b.val;}
};
priority_queue<node> pq;
priority_queue<node> fpq;
int solve1(){
    int localk = cnt;
    if(localk&1)return numeric_limits<long long>::min();
    localk>>=1;
    int fans = 0;
    for(int i = 0;i<=n;++i)vis[i] = 0;
    while(localk){
        localk -= 1;
        auto ed = fpq.top();
        fpq.pop();
        vis[ed.x][ed.y] = 1;
        fans += ed.val;
    }
    return fans+k;
}
int solve2(){
    for(int i = 0;i<=n;++i)vis[i] = 0;
    int localk = cnt;
    int fans = 0;
    while(localk){
        localk-=1;
        auto ed = pq.top();
        pq.pop();
        vis[ed.x][ed.y] = 1;
        fans += ed.val;
    }
    return fans;
}
signed main(){
    cin >> n >> k;
    n *= 2;
    char ch;
    for(int i = 0;i<n;++i)
        for(int j = 0;j<n;++j){
            cin >> ch;
            if(ch == '#')cnt++;
    }
    for(int i = 1;i<=n;++i){
        for(int j = 1;j<=n;++j){
            cin >> gr[i][j];
            pq.push(node(i,j,gr[i][j]));
        }
    }
    for(int i = 1;i<=n;++i){
        for(int j = 1;j<=n>>1;++j){
            fpq.push(node(i,j,gr[i][j] + gr[i][n+1-j]));
        }
    }
    cout << max(solve1(),solve2());
    return 0;
}
0