結果
問題 |
No.2094 Symmetry
|
ユーザー |
![]() |
提出日時 | 2022-10-07 22:22:56 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 143 ms / 2,000 ms |
コード長 | 1,225 bytes |
コンパイル時間 | 3,537 ms |
コンパイル使用メモリ | 236,600 KB |
実行使用メモリ | 9,728 KB |
最終ジャッジ日時 | 2024-06-12 19:15:04 |
合計ジャッジ時間 | 7,994 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
ソースコード
#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; }