結果

問題 No.459 C-VS for yukicoder
ユーザー te-shte-sh
提出日時 2017-12-06 17:39:25
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 1,247 bytes
コンパイル時間 2,484 ms
コンパイル使用メモリ 155,508 KB
実行使用メモリ 5,320 KB
最終ジャッジ日時 2023-09-03 17:15:37
合計ジャッジ時間 20,976 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 RE -
testcase_26 WA -
testcase_27 RE -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 WA -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 RE -
testcase_43 RE -
testcase_44 RE -
testcase_45 RE -
testcase_46 RE -
testcase_47 RE -
testcase_48 RE -
testcase_49 RE -
testcase_50 RE -
testcase_51 RE -
testcase_52 RE -
testcase_53 RE -
testcase_54 RE -
testcase_55 RE -
testcase_56 RE -
testcase_57 RE -
testcase_58 RE -
testcase_59 RE -
testcase_60 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

void main()
{
  auto rd = readln.split.to!(int[]), h = rd[0], w = rd[1], n = rd[2];

  auto b = new int[](w);
  foreach (i; 0..h) {
    auto s = readln.chomp;
    foreach (j; 0..w)
      if (s[j] == '#' && !b[j])
        b[j] = h-i;
  }

  struct Pack { int i, c; int[] b; }
  auto packs = new Pack[](n);
  foreach (i; 0..n) {
    auto c = readln.chomp.to!int;
    packs[i] = Pack(i, c, new int[](3));
  }

  packs.sort!"a.c < b.c";

  auto bi = 0, bj = 0;
  foreach (i; 0..w) {
    while (bi < n && packs[bi].c < i - 2) ++bi;
    while (bj < n && packs[bi].c <= i) ++bj;
    if (b[i] < bj-bi) {
      auto r = b[i];
      foreach (bk; bi..bj) {
        if (r == 0)
          break;
        if (packs[bk].b[i-packs[bk].c] == 0) {
          ++packs[bk].b[i-packs[bk].c];
          --r;
        }
      }
      foreach (bk; bi..bi+r)
        ++packs[bk].b[i-packs[bk].c];
    } else {
      foreach (bk; bi..bj)
        packs[bk].b[i-packs[bk].c] = b[i]/(bj-bi) + (bk-bi < b[i]%(bj-bi));
    }
  }

  packs.sort!"a.i < b.i";

  writeln(packs);

  foreach (pack; packs)
    foreach (i; 0..3) {
      foreach (j; 0..3)
        write(pack.b[j] > i ? "#" : ".");
      writeln;
    }
}
0