結果
| 問題 |
No.459 C-VS for yukicoder
|
| コンテスト | |
| ユーザー |
kuuso1
|
| 提出日時 | 2016-12-10 17:51:35 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 58 ms / 2,000 ms |
| コード長 | 2,692 bytes |
| コンパイル時間 | 1,029 ms |
| コンパイル使用メモリ | 116,884 KB |
| 実行使用メモリ | 33,404 KB |
| 最終ジャッジ日時 | 2024-11-29 01:51:37 |
| 合計ジャッジ時間 | 5,853 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 58 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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));}
}
kuuso1