結果
| 問題 | No.640 76本のトロンボーン |
| コンテスト | |
| ユーザー |
夕叢霧香(ゆうむらきりか)
|
| 提出日時 | 2018-01-26 23:31:52 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,452 bytes |
| 記録 | |
| コンパイル時間 | 1,570 ms |
| コンパイル使用メモリ | 80,372 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-28 02:13:53 |
| 合計ジャッジ時間 | 2,033 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 13 WA * 2 |
ソースコード
#include<algorithm>
#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));
vector<vi>u(n,vi(2));
int ma=0;
rep(i,n){
u[i][0]=s[i][0]=='.';
u[i][1]=s[i][n-1]=='.';
bool ok=true;
for(int j=1;j<n-1;++j)if(s[i][j]=='#')ok=false;
if(!ok)continue;
t[i]=u[i];
}
rep(i,n)ma+=t[i][0]||t[i][1];
rep(i,2){
rep(j,2){
//check
bool ok=true;
rep(k,n-1)if(u[j+k][i]==0)ok=false;
if(!ok)continue;
int tmp=1;
rep(k,n-1)tmp+=t[j+k][1-i];
if(j==0)tmp+=t[n-1][0]||t[n-1][1];
else tmp+=t[0][0]||t[0][1];
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;
vector<string>s(n);
rep(i,n)cin>>s[i];
int ma=0;
rep(qwerty,4){
rep(uiop,2){
ma=max(ma,f(s));
flip(s);
}
s=rotate(s);
}
cout<<ma<<endl;
}
夕叢霧香(ゆうむらきりか)