結果

問題 No.640 76本のトロンボーン
ユーザー ei1333333ei1333333
提出日時 2018-01-26 22:49:32
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,639 bytes
コンパイル時間 2,233 ms
コンパイル使用メモリ 201,620 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-04 04:49:50
合計ジャッジ時間 3,122 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main()
{
  int N;
  string S[75];

  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> S[i];
  }

  auto solve = [&]()
  {
    int ret = 0;
    {
      bool latte = true, malta = true;

      for(int i = 1; i < N; i++) {
        latte &= S[0][i] == '.';
      }
      for(int i = 0; i < N - 1; i++) {
        malta &= S[0][i] == '.';
      }
      ret += latte | malta;
    }

    int cost1 = 0;
    for(int i = 1; i < N; i++) {
      bool latte = true, malta = true;
      for(int j = 1; j < N; j++) {
        latte &= S[i][j] == '.';
      }
      for(int j = 0; j < N - 1; j++) {
        malta &= S[i][j] == '.';
      }
      cost1 += latte | malta;
    }


    int cost2 = 0;
    for(int i = 0; i < N; i++) {
      bool isall = true;
      for(int j = 1; j < N; j++) {
        isall &= S[j][i] == '.';
      }
      cost2 += isall;
    }

    ret += max(cost1, cost2);
    return (ret);
  };

  int ret = 0;
  for(int z = 0; z < 2; z++) {
    for(int j = 0; j < N; j++) {
      reverse(begin(S[j]), end(S[j]));
    }
    for(int i = 0; i < 4; i++) {
      string T[75];

      for(int j = 0; j < N; j++) {
        T[j].resize(N);
        for(int k = 0; k < N; k++) {
          T[j][k] = S[k][N - j - 1];
        }
      }
      swap(T, S);

      ret = max(ret, solve());
    }
  }


  bool beet = true;
  for(int i = 0; i < N; i++) beet &= S[0][i] == '.';
  for(int i = 0; i < N; i++) beet &= S[N - 1][i] == '.';
  for(int i = 0; i < N; i++) beet &= S[i][N - 1] == '.';
  for(int i = 0; i < N; i++) beet &= S[i][0] == '.';
  if(beet) ret = max(ret, 4);


  cout << ret << endl;
}
0