結果

問題 No.459 C-VS for yukicoder
ユーザー tubo28tubo28
提出日時 2016-12-04 19:23:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 19 ms / 2,000 ms
コード長 1,731 bytes
コンパイル時間 2,260 ms
コンパイル使用メモリ 173,456 KB
実行使用メモリ 5,152 KB
最終ジャッジ日時 2023-08-19 06:03:38
合計ジャッジ時間 5,588 ms
ジャッジサーバーID
(参考情報)
judge9 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 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 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 19 ms
5,152 KB
testcase_22 AC 14 ms
4,740 KB
testcase_23 AC 15 ms
5,096 KB
testcase_24 AC 8 ms
4,380 KB
testcase_25 AC 5 ms
4,380 KB
testcase_26 AC 5 ms
4,380 KB
testcase_27 AC 4 ms
4,376 KB
testcase_28 AC 5 ms
4,380 KB
testcase_29 AC 7 ms
4,376 KB
testcase_30 AC 5 ms
4,376 KB
testcase_31 AC 5 ms
4,380 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 6 ms
4,376 KB
testcase_34 AC 7 ms
4,380 KB
testcase_35 AC 2 ms
4,380 KB
testcase_36 AC 6 ms
4,380 KB
testcase_37 AC 3 ms
4,384 KB
testcase_38 AC 6 ms
4,376 KB
testcase_39 AC 2 ms
4,380 KB
testcase_40 AC 5 ms
4,380 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 4 ms
4,380 KB
testcase_43 AC 6 ms
4,380 KB
testcase_44 AC 3 ms
4,380 KB
testcase_45 AC 3 ms
4,384 KB
testcase_46 AC 2 ms
4,380 KB
testcase_47 AC 3 ms
4,376 KB
testcase_48 AC 6 ms
4,380 KB
testcase_49 AC 2 ms
4,380 KB
testcase_50 AC 6 ms
4,380 KB
testcase_51 AC 2 ms
4,376 KB
testcase_52 AC 4 ms
4,380 KB
testcase_53 AC 2 ms
4,380 KB
testcase_54 AC 6 ms
4,376 KB
testcase_55 AC 3 ms
4,376 KB
testcase_56 AC 5 ms
4,380 KB
testcase_57 AC 2 ms
4,380 KB
testcase_58 AC 6 ms
4,376 KB
testcase_59 AC 4 ms
4,376 KB
testcase_60 AC 4 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

void validate_range(int x, int l, int r) { assert(l <= x && x <= r); }

int H, W, N;
vector<string> S;
int C[30010]; // パックiが置かれた列

int need[10010];         // i列目に必要なブロックの数
vector<int> pack[10010]; // i列目に置かれたパックの集合
int cnt[30010];          // パックiが含むブロックの数
int cntc[30010][3];      // パックiがj列目に含むブロックの数

int main() {
  cin >> H >> W >> N;
  validate_range(H, 1, 10000);
  validate_range(W, 3, 10000);
  validate_range((ll)H * W, 3, 30000);
  validate_range(N, 1, max(H * W, 30000));
  S.assign(H, "");
  for (int i = 0; i < H; ++i) {
    cin >> S[i];
    validate_range(S[i].size(), W, W);
  }
  for (int j = 0; j < W; ++j)
    for (int i = 0; i < H; ++i)
      if (S[i][j] == '#')
        ++need[j];
  validate_range(accumulate(need, need + W, 0), 1, H * W);

  for (int i = 0; i < N; ++i) {
    cin >> C[i];
    validate_range(C[i], 0, W - 3);
    for (int j = 0; j < 3; ++j)
      pack[C[i] + j].push_back(i);
  }

  for (int j = 0; j < W; ++j) {
    auto &ps = pack[j];
    sort(ps.begin(), ps.end(), [&](int a, int b) {
      return cnt[a] != cnt[b] ? cnt[a] < cnt[b] : C[a] < C[b];
    });
    int jj = 0;
    while (jj < need[j]) {
      int p = ps[jj % ps.size()];
      int rj = j - C[p];
      if (cntc[p][rj] == 3)
        continue;
      ++cnt[p];
      ++cntc[p][rj];
      ++jj;
    }
  }

  for (int x = 0; x < N; ++x) {
    char ans[3][4] = {"...", "...", "..."};
    for (int j = 0; j < 3; ++j)
      for (int i = 0; i < cntc[x][j]; ++i)
        ans[i][j] = '#';
    for (int i = 0; i < 3; ++i)
      puts(ans[i]);
  }
}
0