結果

問題 No.459 C-VS for yukicoder
ユーザー kuuso1kuuso1
提出日時 2016-12-10 17:51:35
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 96 ms / 2,000 ms
コード長 2,692 bytes
コンパイル時間 3,001 ms
コンパイル使用メモリ 109,344 KB
実行使用メモリ 30,960 KB
最終ジャッジ日時 2023-08-19 10:23:26
合計ジャッジ時間 10,449 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 59 ms
18,820 KB
testcase_01 AC 58 ms
20,868 KB
testcase_02 AC 60 ms
22,760 KB
testcase_03 AC 57 ms
22,808 KB
testcase_04 AC 57 ms
20,900 KB
testcase_05 AC 59 ms
20,784 KB
testcase_06 AC 60 ms
20,708 KB
testcase_07 AC 59 ms
20,696 KB
testcase_08 AC 61 ms
20,840 KB
testcase_09 AC 59 ms
20,776 KB
testcase_10 AC 60 ms
22,772 KB
testcase_11 AC 59 ms
22,732 KB
testcase_12 AC 59 ms
20,760 KB
testcase_13 AC 59 ms
20,896 KB
testcase_14 AC 58 ms
18,712 KB
testcase_15 AC 61 ms
20,828 KB
testcase_16 AC 60 ms
18,728 KB
testcase_17 AC 59 ms
22,768 KB
testcase_18 AC 58 ms
20,780 KB
testcase_19 AC 61 ms
20,644 KB
testcase_20 AC 61 ms
20,712 KB
testcase_21 AC 96 ms
30,960 KB
testcase_22 AC 91 ms
30,536 KB
testcase_23 AC 90 ms
27,916 KB
testcase_24 AC 73 ms
26,548 KB
testcase_25 AC 63 ms
20,776 KB
testcase_26 AC 64 ms
20,668 KB
testcase_27 AC 62 ms
20,644 KB
testcase_28 AC 63 ms
20,776 KB
testcase_29 AC 71 ms
23,032 KB
testcase_30 AC 64 ms
20,656 KB
testcase_31 AC 66 ms
22,756 KB
testcase_32 AC 59 ms
18,732 KB
testcase_33 AC 66 ms
22,900 KB
testcase_34 AC 68 ms
24,804 KB
testcase_35 AC 60 ms
20,720 KB
testcase_36 AC 66 ms
22,768 KB
testcase_37 AC 60 ms
20,900 KB
testcase_38 AC 67 ms
22,948 KB
testcase_39 AC 60 ms
22,824 KB
testcase_40 AC 66 ms
22,684 KB
testcase_41 AC 60 ms
22,828 KB
testcase_42 AC 63 ms
22,764 KB
testcase_43 AC 66 ms
22,964 KB
testcase_44 AC 61 ms
20,860 KB
testcase_45 AC 60 ms
18,724 KB
testcase_46 AC 59 ms
20,772 KB
testcase_47 AC 58 ms
20,844 KB
testcase_48 AC 66 ms
24,800 KB
testcase_49 AC 60 ms
20,772 KB
testcase_50 AC 65 ms
24,908 KB
testcase_51 AC 59 ms
20,764 KB
testcase_52 AC 63 ms
22,752 KB
testcase_53 AC 59 ms
20,780 KB
testcase_54 AC 66 ms
22,816 KB
testcase_55 AC 62 ms
20,668 KB
testcase_56 AC 65 ms
20,896 KB
testcase_57 AC 59 ms
20,704 KB
testcase_58 AC 67 ms
20,732 KB
testcase_59 AC 61 ms
22,772 KB
testcase_60 AC 63 ms
22,900 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		List<int>[] L = new List<int>[W];
		for(int i=0;i<W;i++) L[i] = new List<int>();
		for(int i=0;i<N;i++){
			L[C[i]].Add(i);
		}
		
		int[] Tot = new int[W];
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				if(S[i][j] == '#') Tot[j]++;
			}
		}
		int[][] pk = new int[N][];
		for(int i=0;i<N;i++) pk[i] = new int[3];
		
		for(int w=0;w<W;w++){
			if(L[w].Count==0)continue;
			foreach(var n in L[w]){
				for(int t=0;t<3;t++){
					if(Tot[w+t] == 0) continue;
					Tot[w+t]--;
					pk[n][t]++;
					break;
				}
			}
		}
		
		Debug.Write("ok");
		Debug.Assert(chk(pk));
		
		for(int w=0;w<W;w++){
			foreach(var n in L[w]){
				for(int t=0;t<3;t++){
					if(pk[n][t] == 3) continue;
					if(Tot[w+t] == 0) continue;
					int rm = Math.Min(Tot[w+t],3 - pk[n][t]);
					Tot[w+t] -= rm;
					pk[n][t] += rm;
				}
			}
		}
		
		Debug.Assert(chk2(pk));
		Debug.Assert(Tot.Select(c => c==0).Aggregate(true,(s,b)=>s&b));
		
		var sb = new StringBuilder();
		for(int i=0;i<N;i++){
			var ca = new char[3][];
			for(int h=0;h<3;h++){
				ca[h] = new char[3];
				for(int w=0;w<3;w++) ca[h][w] = '.';
			}
			for(int w=0;w<3;w++){
				for(int h=0;h<pk[i][w];h++){
					ca[h][w] = '#';
				}
			}
			for(int h=0;h<3;h++) sb.AppendLine(new String(ca[h]));
		}
		
		Console.Write(sb.ToString());
		
		
	}
	
	bool chk(int[][] pk){
		bool ret = true;
		for(int i=0;i<pk.Length;i++) ret &= (pk[i][0] != 0 ||pk[i][1] != 0 ||pk[i][2] != 0 );
		return ret;
	}
	bool chk2(int[][] pk){
		bool ret = true;
		for(int i=0;i<pk.Length;i++) ret &= (pk[i][0] <=3 && pk[i][1] <= 3 || pk[i][2] <=3 );
		return ret;
	}
	
	
	int H,W,N;
	String[] S;
	int[] C;
	public Sol(){
		var d = ria();
		H = d[0]; W = d[1]; N = d[2];
		S = new String[H];
		for(int i=0;i<H;i++) S[i] = rs();
		C = new int[N];
		for(int i=0;i<N;i++) C[i] = ri();
	}
	
	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}
0