結果

問題 No.291 黒い文字列
ユーザー kuuso1kuuso1
提出日時 2015-10-16 23:44:43
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 3,141 bytes
コンパイル時間 2,498 ms
コンパイル使用メモリ 108,556 KB
実行使用メモリ 24,824 KB
最終ジャッジ日時 2023-09-29 02:00:54
合計ジャッジ時間 5,514 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
20,760 KB
testcase_01 AC 58 ms
22,616 KB
testcase_02 AC 59 ms
24,536 KB
testcase_03 AC 60 ms
22,700 KB
testcase_04 AC 59 ms
24,496 KB
testcase_05 AC 57 ms
20,520 KB
testcase_06 AC 58 ms
24,624 KB
testcase_07 AC 61 ms
24,564 KB
testcase_08 AC 58 ms
22,628 KB
testcase_09 AC 58 ms
24,560 KB
testcase_10 AC 58 ms
22,436 KB
testcase_11 AC 57 ms
22,564 KB
testcase_12 AC 60 ms
22,524 KB
testcase_13 AC 58 ms
24,632 KB
testcase_14 AC 60 ms
22,688 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 58 ms
24,544 KB
testcase_22 WA -
testcase_23 AC 58 ms
24,656 KB
testcase_24 WA -
testcase_25 AC 59 ms
22,748 KB
testcase_26 AC 61 ms
24,608 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;

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

class Sol{
	public void Solve(){
		
		int N=S.Length;
		
		HashSet<ATMTN> D=new HashSet<ATMTN>();
		D.Add(new ATMTN(0,0,0,0,0));
		
		for(int n=0;n<N;n++){
//Console.WriteLine("n={0}",n);
//foreach(var k in D)Console.WriteLine("\t{0},{1},{2},{3},{4}",k.K,k.U,k.R,k.O,k.I);
			HashSet<ATMTN> Dnxt=new HashSet<ATMTN>();
			switch(S[n]){
				case 'K':
					foreach(var a in D){
						var anew=new ATMTN(a);
						//Dnxt.Add(anew);
						if(anew.K<20){
							anew.K++;
							Dnxt.Add(anew);
						}
					}
					break;
				case 'U':
					foreach(var a in D){
						var anew=new ATMTN(a);
						if(anew.K>0&& anew.U<20){
							anew.U++;anew.K--;
							Dnxt.Add(anew);
						}else{
							Dnxt.Add(anew);
						}
					}
					break;
				case 'R':
					foreach(var a in D){
						var anew=new ATMTN(a);
						if(anew.U>0 && anew.R<20){
							anew.R++;anew.U--;
							Dnxt.Add(anew);
						}else{
							Dnxt.Add(anew);
						}
					}
					break;
				case 'O':
					foreach(var a in D){
						var anew=new ATMTN(a);
						if(anew.R>0 && anew.O<20){
							anew.O++;anew.R--;
							Dnxt.Add(anew);
						}else{
							Dnxt.Add(anew);
						}
					}
					break;
				case 'I':
					foreach(var a in D){
						var anew=new ATMTN(a);
						if(anew.O>0 && anew.I<20){
							anew.I++;anew.O--;
							Dnxt.Add(anew);
						}else{
							Dnxt.Add(anew);
						}
					}
					break;
				case '?':
					foreach(var a in D){
						var anew=new ATMTN(a);
						if(anew.O>0 && anew.I<20){
							anew.I++;anew.O--;
							Dnxt.Add(anew);
						}else 
						if(anew.R>0 && anew.O<20){
							anew.O++;anew.R--;
							Dnxt.Add(anew);
						}else
						if(anew.U>0 && anew.R<20){
							anew.R++;anew.U--;
							Dnxt.Add(anew);
						}else
						if(anew.K>0 && anew.U<20){
							anew.U++;anew.K--;
							Dnxt.Add(anew);
						}else
						if(anew.K<20){
							anew.K++;
							Dnxt.Add(anew);
						}

					}
					break;
		
				default:
					foreach(var a in D){
						var anew=new ATMTN(a);
						Dnxt.Add(anew);
					}
					break;
		
			}
			D=Dnxt;
		}
		
		int ans=0;
		foreach(var k in D){
			ans=Math.Max(ans,k.I);
		}
		Console.WriteLine(ans);
		
		
		
		
	}
	String S;
	public Sol(){
		S=rs();
	}

	struct ATMTN{
		public int K,U,R,O,I;
		public ATMTN(int k,int u,int r,int o,int i){
			K=k;U=u;R=r;O=o;I=i;
		}
		public ATMTN(ATMTN a){
			K=a.K;U=a.U;R=a.R;O=a.O;I=a.I;
		}
	}


	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(){return Console.ReadLine().Split(' ');}
	static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}
	static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}
	static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}
}
0