結果
| 問題 |
No.2094 Symmetry
|
| コンテスト | |
| ユーザー |
Haa
|
| 提出日時 | 2022-10-07 21:43:23 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 149 ms / 2,000 ms |
| コード長 | 1,115 bytes |
| コンパイル時間 | 1,829 ms |
| コンパイル使用メモリ | 178,664 KB |
| 実行使用メモリ | 8,948 KB |
| 最終ジャッジ日時 | 2024-06-12 06:45:19 |
| 合計ジャッジ時間 | 7,047 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 34 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) v.begin(),v.end()
template<typename T> bool chmax(T &x, const T &y) {return (x<y)?(x=y,true):false;};
template<typename T> bool chmin(T &x, const T &y) {return (x>y)?(x=y,true):false;};
constexpr ll MOD=998244353;
constexpr ll INF=2e18;
int main(){
ll n, k; cin >> n >> k;
ll m=n*2;
vector<string> s(m);
REP(i,m) cin >> s[i];
VVI c(m,VI(m));
REP(i,m)REP(j,m) cin >> c[i][j];
ll cnt=0;
REP(i,m)REP(j,m){
if(s[i][j]=='#')
cnt++;
}
ll ans=-INF;
if(cnt%2==0){
VI a;
REP(i,m)REP(j,n){
a.push_back(c[i][j]+c[i][m-1-j]);
}
sort(ALL(a),greater<ll>());
ll sum=k;
REP(i,cnt/2) sum+=a[i];
chmax(ans,sum);
}
VI b;
REP(i,m)REP(j,m) b.push_back(c[i][j]);
sort(ALL(b),greater<ll>());
ll sum=0;
REP(i,cnt) sum+=b[i];
chmax(ans,sum);
cout << ans << endl;
return 0;
}
Haa