結果

問題 No.291 黒い文字列
ユーザー kuuso1kuuso1
提出日時 2015-10-16 23:35:11
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 3,227 bytes
コンパイル時間 2,534 ms
コンパイル使用メモリ 110,496 KB
実行使用メモリ 29,196 KB
最終ジャッジ日時 2023-09-29 01:58:40
合計ジャッジ時間 8,203 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
22,508 KB
testcase_01 AC 60 ms
22,500 KB
testcase_02 AC 62 ms
22,672 KB
testcase_03 AC 61 ms
22,500 KB
testcase_04 AC 61 ms
22,604 KB
testcase_05 AC 60 ms
20,408 KB
testcase_06 AC 60 ms
24,572 KB
testcase_07 AC 60 ms
22,452 KB
testcase_08 AC 61 ms
22,436 KB
testcase_09 AC 60 ms
22,564 KB
testcase_10 AC 72 ms
26,548 KB
testcase_11 AC 182 ms
29,196 KB
testcase_12 AC 159 ms
29,040 KB
testcase_13 AC 60 ms
22,548 KB
testcase_14 AC 61 ms
22,640 KB
testcase_15 AC 61 ms
20,468 KB
testcase_16 TLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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);
						Dnxt.Add(anew);
						if(anew.K>0&& anew.U<20){
							anew.U++;anew.K--;
							Dnxt.Add(anew);
						}
						
					}
					break;
				case 'R':
					foreach(var a in D){
						var anew=new ATMTN(a);
						Dnxt.Add(anew);
						if(anew.U>0 && anew.R<20){
							anew.R++;anew.U--;
							Dnxt.Add(anew);
						}
					}
					break;
				case 'O':
					foreach(var a in D){
						var anew=new ATMTN(a);
						Dnxt.Add(anew);
						if(anew.R>0 && anew.O<20){
							anew.O++;anew.R--;
							Dnxt.Add(anew);
						}
					}
					break;
				case 'I':
					foreach(var a in D){
						var anew=new ATMTN(a);
						Dnxt.Add(anew);
						if(anew.O>0 && anew.I<20){
							anew.I++;anew.O--;
							Dnxt.Add(anew);
						}
					}
					break;
				case '?':
					foreach(var a in D){
						var anew=new ATMTN(a);
						Dnxt.Add(anew);
						
						anew=new ATMTN(a);
						if(anew.K<20){
							anew.K++;
							Dnxt.Add(anew);
						}
						anew=new ATMTN(a);
						if(anew.K>0 && anew.U<20){
							anew.U++;anew.K--;
							Dnxt.Add(anew);
						}
						anew=new ATMTN(a);
						if(anew.U>0 && anew.R<20){
							anew.R++;anew.U--;
							Dnxt.Add(anew);
						}
						anew=new ATMTN(a);
						if(anew.R>0 && anew.O<20){
							anew.O++;anew.R--;
							Dnxt.Add(anew);
						}
						anew=new ATMTN(a);
						if(anew.O>0 && anew.I<20){
							anew.I++;anew.O--;
							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