結果
問題 | No.2094 Symmetry |
ユーザー |
![]() |
提出日時 | 2022-10-07 22:36:38 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 146 ms / 2,000 ms |
コード長 | 1,019 bytes |
コンパイル時間 | 1,741 ms |
コンパイル使用メモリ | 176,668 KB |
実行使用メモリ | 9,728 KB |
最終ジャッジ日時 | 2024-06-12 19:44:46 |
合計ジャッジ時間 | 5,959 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
ソースコード
#include<bits/stdc++.h> // #include<atcoder/all> // #include<boost/multiprecision/cpp_int.hpp> using namespace std; // using namespace atcoder; // using bint = boost::multiprecision::cpp_int; using ll = long long; using ull = unsigned long long; using P = pair<int,int>; #define rep(i,n) for(ll i = 0;i < (ll)n;i++) #define ALL(x) (x).begin(),(x).end() #define MOD 1000000007 // #define MOD 998244353 int main(){ ll n,K; cin >> n >> K; vector<string> s(2*n); rep(i,2*n)cin >> s[i]; vector<vector<ll>> c(2*n,vector<ll>(2*n)); vector<ll> v(4*n*n); rep(i,2*n)rep(j,2*n)cin >> c[i][j],v[i*2*n + j] = c[i][j]; int cnt = 0; rep(i,2*n)rep(j,2*n)cnt += (s[i][j] == '#'); ll res = 0; if(cnt%2 == 0){ vector<ll> g(4*n*n,-(1ll << 60)); rep(i,2*n)rep(j,n)g[i*2*n + j] = c[i][j] + c[i][2*n-j-1]; sort(ALL(g),greater<ll>()); rep(i,cnt/2)res += g[i]; res += K; } sort(ALL(v),greater<ll>()); ll ans = 0; rep(i,cnt)ans += v[i]; cout << max(res,ans) << "\n"; return 0; }