結果

問題 No.640 76本のトロンボーン
ユーザー 夕叢霧香(ゆうむらきりか)夕叢霧香(ゆうむらきりか)
提出日時 2018-01-26 23:31:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,452 bytes
コンパイル時間 960 ms
コンパイル使用メモリ 80,628 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-27 19:54:20
合計ジャッジ時間 1,902 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 WA -
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 WA -
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0