結果

問題 No.640 76本のトロンボーン
ユーザー te-shte-sh
提出日時 2018-04-20 11:46:56
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 1,483 bytes
コンパイル時間 752 ms
コンパイル使用メモリ 106,764 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-03 20:02:38
合計ジャッジ時間 1,436 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void pickV(R,T...)(ref R r,ref T t){foreach(ref v;t)pick(r,v);}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readC(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=rdsp;foreach(ref v;t)pick(r,v[i]);}}

const r = r"^\.+$";

void main()
{
  int n; readV(n);
  string[] s; readC(n, s);

  auto t = s.dup.transposed.map!(array).array;
  auto r1 = max(calc1(n, s), calc2(n, s), calc3(n, s));
  auto r2 = max(calc1(n, t), calc2(n, t), calc3(n, t));
  auto r3 = calc4(n, s, t);

  writeln(max(r1, r2, r3));
}

auto canPut(R)(R s)
{
  return s.all!(c => c == '.');
}

auto calc1(R)(int n, R s)
{
  if (!s[0].take(n-1).canPut && !s[0].drop(1).canPut) return 0;
  auto t = 1;
  foreach (i; 0..n)
    if (s.transversal(i).drop(1).canPut) ++t;
  return t;
}

auto calc2(R)(int n, R s)
{
  if (!s[$-1].take(n-1).canPut && !s[$-1].drop(1).canPut) return 0;
  auto t = 1;
  foreach (i; 0..n)
    if (s.transversal(i).take(n-1).canPut) ++t;
  return t;
}

auto calc3(R)(int n, R s)
{
  auto t = 0;
  foreach (i; 0..n)
    if (s.transversal(i).take(n-1).canPut || s.transversal(i).drop(1).canPut) ++t;
  return t;
}

auto calc4(R1, R2)(int n, R1 s, R2 t)
{
  return s[0].canPut && s[$-1].canPut && t[0].canPut && t[$-1].canPut ? 4 : 0;
}
0