結果
| 問題 | No.640 76本のトロンボーン |
| コンテスト | |
| ユーザー |
夕叢霧香(ゆうむらきりか)
|
| 提出日時 | 2018-01-27 00:06:49 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,397 bytes |
| 記録 | |
| コンパイル時間 | 1,175 ms |
| コンパイル使用メモリ | 78,564 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-28 03:24:14 |
| 合計ジャッジ時間 | 1,723 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 13 WA * 2 |
ソースコード
#include<algorithm>
#include<cassert>
#include<iostream>
#include<vector>
using namespace std;
typedef long long lint;
typedef vector<int>vi;
typedef pair<int,int>pii;
#define rep(i,n)for(int i=0;i<(int)(n);++i)
vector<string> rotate(const vector<string> &s){
int n=s.size();
vector<string>r(n,string(n,'*'));
rep(i,n){
rep(j,n){
r[i][j]=s[j][n-1-i];
}
}
return r;
}
void flip(vector<string> &s){
int n=s.size();
rep(i,n){
rep(j,n/2){
swap(s[i][j],s[i][n-1-j]);
}
}
}
int f(const vector<string> &s){
int n=s.size();
vector<vi>t(n,vi(2,0));
int ma=0;
rep(i,n){
bool ok=true;
for(int j=1;j<n-1;++j)if(s[i][j]=='#')ok=false;
if(!ok)continue;
t[i][0]=s[i][0]=='.'?1:0;
t[i][1]=s[i][n-1]=='.'?1:0;
}
rep(i,n)ma+=t[i][0]||t[i][1]?1:0;
//check
bool ok=true;
rep(k,n-1)if(s[k][0]=='#')ok=false;
if(ok){
int tmp=1;
rep(k,n-1)tmp+=t[k][1];
tmp+=t[n-1][0]||t[n-1][1]?1:0;
ma=max(ma,tmp);
}
if(0){
rep(i,n)cerr<<s[i]<<endl;
rep(i,n)cerr<<t[i][0]<<" "<<t[i][1]<<endl;
cerr<<"ma="<<ma<<endl;
cerr<<endl;
}
return ma;
}
int main(){
int n;
cin>>n;
assert(n>=3&&n<=75);
vector<string>s(n);
rep(i,n)cin>>s[i];
rep(i,n)assert((int)s.size()==n);
int ma=0;
rep(qwerty,4){
rep(uiop,2){
ma=max(ma,f(s));
flip(s);
}
s=rotate(s);
}
cout<<ma<<endl;
}
夕叢霧香(ゆうむらきりか)