結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー te-sh
提出日時 2017-05-11 14:16:55
言語 D
(dmd 2.109.1)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 585 bytes
コンパイル時間 953 ms
コンパイル使用メモリ 109,396 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-12 19:10:21
合計ジャッジ時間 1,989 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 46
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto d = readln.chomp.to!int;
  auto s1 = readln.chomp, s2 = readln.chomp, s = s1 ~ s2;

  auto r = s.group.filter!"a[0] == 'o'".map!"a[1]".maxElement;
  foreach (cd; 1..d+1) {
    auto wd = 'x'.repeat.take(cd).array, hd = 'o'.repeat.take(cd).array;
    auto ts = wd ~ s ~ wd;
    foreach (i; 0..ts.length-cd+1) {
      if (ts[i..i+cd] == wd) {
        auto t = ts.dup;
        t[i..i+cd] = hd;
        r = max(r, t.group.filter!"a[0] == 'o'".map!"a[1]".maxElement);
      }
    }
  }

  writeln(r);
}
0