結果

問題 No.459 C-VS for yukicoder
ユーザー tnakao0123tnakao0123
提出日時 2016-12-10 01:50:58
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,966 bytes
コンパイル時間 1,951 ms
コンパイル使用メモリ 90,904 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-19 06:51:18
合計ジャッジ時間 5,522 ms
ジャッジサーバーID
(参考情報)
judge10 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 459.cc: No.459 C-VS for yukicoder - yukicoder
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_W = 10000;
const int MAX_N = 30000;

/* typedef */

struct Pack {
  int id, x, bn, bs[3];
  Pack() {}
  bool operator<(const Pack &p) const {
    return bn < p.bn || (bn == p.bn && id < p.id);
  }

  void print() {
    for (int y = 0; y < 3; y++) {
      for (int i = 0; i < 3; i++) putchar(y < bs[i] ? '#' : '.');
      putchar('\n');
    }
  }
};

/* global variables */

int flds[MAX_W];
Pack ps[MAX_N];

/* subroutines */

bool comp_x(const Pack &p0, const Pack &p1) {
  return p0.x < p1.x || (p0.x == p1.x && p0.id < p1.id);
}

bool comp_id(const Pack &p0, const Pack &p1) {
  return p0.id < p1.id;
}

/* main */

int main() {
  int h, w, n;
  cin >> h >> w >> n;

  for (int y = 0; y < h; y++) {
    string s;
    cin >> s;
    for (int x = 0; x < w; x++)
      if (s[x] == '#') flds[x]++;
  }
  //for (int x = 0; x < w; x++) printf("%d", flds[x]); putchar('\n');

  for (int i = 0; i < n; i++) {
    ps[i].id = i;
    cin >> ps[i].x;
    ps[i].bn = ps[i].bs[0] = ps[i].bs[1] = ps[i].bs[2] = 0;
  }
  sort(ps, ps + n, comp_x);

  queue<Pack *> q;
  for (int i = 0; i < n; i++) q.push(&ps[i]);
  
  while (! q.empty()) {
    Pack *pt = q.front(); q.pop();

    int maxf = 0, maxi = -1;
    for (int i = 0; i < 3; i++) {
      int &fi = flds[pt->x + i];
      if (pt->bs[i] < 3 && maxf < fi) maxf = fi, maxi = i;
    }
    if (maxf <= 0) continue;

    flds[pt->x + maxi]--;
    pt->bs[maxi]++;
    pt->bn++;
    q.push(pt);
  }

  sort(ps, ps + n, comp_id);
  for (int i = 0; i < n; i++) ps[i].print();
  return 0;
}
0