結果

問題 No.459 C-VS for yukicoder
ユーザー tubo28
提出日時 2016-12-04 19:15:59
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 21 ms / 2,000 ms
コード長 2,063 bytes
コンパイル時間 1,796 ms
コンパイル使用メモリ 178,076 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-28 19:52:16
合計ジャッジ時間 4,347 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 58
権限があれば一括ダウンロードができます

ソースコード

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]; // ij
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]);
}
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0