結果

問題 No.459 C-VS for yukicoder
ユーザー uwiuwi
提出日時 2016-12-10 00:06:08
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 4,007 bytes
コンパイル時間 4,675 ms
コンパイル使用メモリ 91,524 KB
実行使用メモリ 45,372 KB
最終ジャッジ日時 2024-05-06 13:29:04
合計ジャッジ時間 17,180 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
37,020 KB
testcase_01 AC 49 ms
36,768 KB
testcase_02 WA -
testcase_03 AC 46 ms
36,588 KB
testcase_04 AC 45 ms
36,848 KB
testcase_05 AC 47 ms
37,044 KB
testcase_06 WA -
testcase_07 AC 49 ms
37,064 KB
testcase_08 WA -
testcase_09 AC 46 ms
37,072 KB
testcase_10 AC 46 ms
36,656 KB
testcase_11 WA -
testcase_12 AC 47 ms
36,736 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 89 ms
37,560 KB
testcase_16 WA -
testcase_17 AC 56 ms
36,820 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 110 ms
39,196 KB
testcase_26 AC 108 ms
39,500 KB
testcase_27 AC 106 ms
39,720 KB
testcase_28 AC 110 ms
39,516 KB
testcase_29 AC 137 ms
40,236 KB
testcase_30 AC 112 ms
39,656 KB
testcase_31 WA -
testcase_32 AC 53 ms
36,864 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 57 ms
36,884 KB
testcase_36 WA -
testcase_37 AC 54 ms
37,068 KB
testcase_38 WA -
testcase_39 AC 69 ms
37,432 KB
testcase_40 WA -
testcase_41 AC 49 ms
36,760 KB
testcase_42 WA -
testcase_43 AC 132 ms
38,952 KB
testcase_44 WA -
testcase_45 WA -
testcase_46 AC 88 ms
38,664 KB
testcase_47 AC 64 ms
37,004 KB
testcase_48 AC 131 ms
39,664 KB
testcase_49 AC 54 ms
36,932 KB
testcase_50 WA -
testcase_51 AC 53 ms
37,008 KB
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 AC 101 ms
38,940 KB
testcase_56 WA -
testcase_57 AC 53 ms
36,732 KB
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

package adv2016;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.InputMismatchException;

public class N459 {
	InputStream is;
	PrintWriter out;
	String INPUT = "";
	
	void solve()
	{
		int h = ni(), w = ni(), K = ni();
		char[][] map = nm(h, w);
		int[] hs = new int[w+2];
		for(int i = 0;i < w;i++){
			for(int j = 0;j < h;j++){
				if(map[j][i] == '#'){
					hs[i]++;
				}
			}
		}
		int[] a = na(K);
		int[][] bs = new int[K][3];
		for(int i = 0;i < K;i++)bs[i][0] = 1;
		for(int v : a){
			hs[v]--;
		}
		int[][] ai = new int[K][];
		for(int i = 0;i < K;i++){
			ai[i] = new int[]{a[i], i};
		}
		Arrays.sort(ai, new Comparator<int[]>() {
			public int compare(int[] a, int[] b) {
				return a[0] - b[0];
			}
		});
		for(int i = 0;i < K;i++){
			for(int j = 0;j < 3;j++){
				int plus = Math.min(3-bs[ai[i][1]][j], hs[ai[i][0]+j]);
				hs[ai[i][0]+j] -= plus;
				bs[ai[i][1]][j] += plus;
			}
		}
		for(int i = 0;i < K;i++){
			for(int j = 0;j < 3;j++){
				for(int k = 0;k < 3;k++){
					if(bs[i][k] > 0){
						out.print("#");
						bs[i][k]--;
					}else{
						out.print(".");
					}
				}
				out.println();
			}
		}
		out.println();
	}
	
	void run() throws Exception
	{
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);
		
		long s = System.currentTimeMillis();
		solve();
		out.flush();
		if(!INPUT.isEmpty())tr(System.currentTimeMillis()-s+"ms");
//		Thread t = new Thread(null, null, "~", Runtime.getRuntime().maxMemory()){
//			@Override
//			public void run() {
//				long s = System.currentTimeMillis();
//				solve();
//				out.flush();
//				if(!INPUT.isEmpty())tr(System.currentTimeMillis()-s+"ms");
//			}
//		};
//		t.start();
//		t.join();
	}
	
	public static void main(String[] args) throws Exception { new N459().run(); }
	
	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;
	
	private int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}
	
	private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }
	
	private double nd() { return Double.parseDouble(ns()); }
	private char nc() { return (char)skip(); }
	
	private String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	
	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}
	
	private int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}
	
	private long[] nal(int n)
	{
		long[] a = new long[n];
		for(int i = 0;i < n;i++)a[i] = nl();
		return a;
	}
	
	private char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}
	
	private int[][] nmi(int n, int m) {
		int[][] map = new int[n][];
		for(int i = 0;i < n;i++)map[i] = na(m);
		return map;
	}
	
	private int ni() { return (int)nl(); }
	
	private long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}
		
		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}
	
	private static void tr(Object... o) { System.out.println(Arrays.deepToString(o)); }
}
0