結果

問題 No.459 C-VS for yukicoder
ユーザー femtofemto
提出日時 2016-12-10 03:02:27
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 114 ms / 2,000 ms
コード長 1,541 bytes
コンパイル時間 1,648 ms
コンパイル使用メモリ 174,596 KB
実行使用メモリ 5,212 KB
最終ジャッジ日時 2023-08-19 08:10:50
合計ジャッジ時間 5,592 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


struct Block {
	int id, pos;
	int num[3];
	Block(int id, int pos) : id(id), pos(pos) {
		for(int i = 0; i < 3; i++) {
			num[i] = 0;
		}
	}
};
bool comp1(Block b1, Block b2) {
	return b1.pos < b2.pos;
}
bool comp2(Block b1, Block b2) {
	return b1.id < b2.id;
}

int num[10000];
vector<P> p[10000];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int H, W, N;
	cin >> H >> W >> N;

	for(int i = 0; i < H; i++) {
		for(int j = 0; j < W; j++) {
			char c;
			cin >> c;
			if(c == '#') num[j]++;
		}
	}

	vector<Block> block;
	for(int i = 0; i < N; i++) {
		int pos;
		cin >> pos;
		block.push_back(Block(i, pos));

	}
	sort(block.begin(), block.end(), comp1);

	for(int i = 0; i < N; i++) {
		for(int j = 0; j < 3; j++) {
			p[block[i].pos + j].push_back(P(i, j));
		}
	}
	for(auto& b : block) {
		bool flag = false;
		for(int i = 0; i < 3; i++) {
			if(num[b.pos + i] > 0) {
				num[b.pos + i]--;
				b.num[i]++;
				flag = true;
				break;
			}
		}
		assert(flag);
	}

	for(int j = 0; j < W; j++) {
		if(num[j] == 0) continue;
		for(auto v : p[j]) {
			int idx = v.first, col = v.second;
			while(block[idx].num[col] < 3 && num[j] > 0) {
				block[idx].num[col]++;
				num[j]--;
			}
		}
		assert(num[j] == 0);
	}

	sort(block.begin(), block.end(), comp2);

	for(auto b : block) {
		for(int i = 0; i < 3; i++) {
			for(int j = 0; j < 3; j++) {
				if(i >= 3 - b.num[j]) cout << '#';
				else cout << '.';
			}
			cout << endl;
		}
	}
}
0