結果

問題 No.459 C-VS for yukicoder
ユーザー tubo28tubo28
提出日時 2016-12-04 19:15:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 20 ms / 2,000 ms
コード長 2,063 bytes
コンパイル時間 2,103 ms
コンパイル使用メモリ 175,208 KB
実行使用メモリ 5,340 KB
最終ジャッジ日時 2023-08-19 06:03:29
合計ジャッジ時間 5,826 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(c) begin(c), end(c)
#define dump(x) //cerr << __LINE__ << ":\t" #x " = " << x << endl

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, "");
    rep(i, H){
        cin >> S[i];
        validate_range(S[i].size(), W, W);
        dump(S[i]);
    }
    rep(j, W) rep(i, H) if(S[i][j] == '#') ++need[j];
    validate_range(accumulate(need, need + W, 0), 1, H*W);
    
    rep(i, N) {
        cin >> C[i];
        validate_range(C[i], 0, W-3);
        rep(j, 3) pack[C[i]+j].push_back(i);
    }

    rep(j, W){
        dump(j);
        auto &ps = pack[j];
        sort(all(pack[j]), [&](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()];
            dump(p);
            dump(C[p]);
            int rj = j - C[p];
            // validate_range(rj, 0, 2);
            if(cntc[p][rj] == 3) continue;
            ++cnt[p];
            ++cntc[p][rj];
            ++jj;
        }
    }

    rep(x, N){
        validate_range(cnt[x], 1, 9);
        dump(cnt[x]);
        char ans[3][4] = { "...", "...", "..." };
        rep(j, 3){
            validate_range(cntc[x][j], 0, 3);
            dump(cntc[x][j]);
            rep(i, cntc[x][j]){
                ans[i][j] = '#';
            }
        }
        rep(i, 3) puts(ans[i]);
    }
}
0