結果
| 問題 |
No.640 76本のトロンボーン
|
| コンテスト | |
| ユーザー |
beet
|
| 提出日時 | 2018-01-26 22:37:57 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,326 bytes |
| コンパイル時間 | 1,772 ms |
| コンパイル使用メモリ | 167,936 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-28 01:16:37 |
| 合計ジャッジ時間 | 2,590 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 13 WA * 2 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T> void chmin(T &a,T b){if(a>b) a=b;}
template<typename T> void chmax(T &a,T b){if(a<b) a=b;}
signed main(){
Int n;
cin>>n;
vector<string> s(n);
for(Int i=0;i<n;i++) cin>>s[i];
auto rot=[](const vector<string> &s){
Int n=s.size();
auto t=s;
for(Int i=0;i<n;i++)
for(Int j=0;j<n;j++)
t[i][j]=s[n-(j+1)][i];
return t;
};
Int ans=0;
for(Int k=0;k<4;k++){
vector<vector<Int> > a(2,vector<Int>(n,0));
for(Int i=0;i<n;i++){
Int k=count(s[i].begin(),s[i].end(),'#');
if(k>1) continue;
if(k==0) a[0][i]=a[1][i]=1;
if(s[i].front()=='#') a[1][i]=1;
if(s[i].back()=='#') a[0][i]=1;
}
{
Int tmp=0;
for(Int i=0;i<n;i++)
tmp+=max(a[0][i],a[1][i]);
chmax(ans,tmp);
}
{
Int cnt=0;
for(Int i=0;i<n-1;i++) cnt+=s[i][0]=='.';
if(cnt==n-1){
Int tmp=1;
for(Int i=0;i<n-1;i++)
tmp+=a[1][i];
tmp+=max(a[0][n-1],a[1][n-1]);
chmax(ans,tmp);
}
}
{
Int cnt=0;
for(Int i=1;i<n;i++) cnt+=s[i][0]=='.';
if(cnt==n-1){
Int tmp=1;
tmp+=max(a[0][0],a[1][0]);
for(Int i=1;i<n;i++)
tmp+=a[1][i];
chmax(ans,tmp);
}
}
s=rot(s);
}
cout<<ans<<endl;
return 0;
}
beet