結果

問題 No.291 黒い文字列
ユーザー kuuso1kuuso1
提出日時 2015-10-16 23:19:30
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 3,633 bytes
コンパイル時間 4,402 ms
コンパイル使用メモリ 110,188 KB
実行使用メモリ 33,260 KB
最終ジャッジ日時 2023-09-29 01:50:31
合計ジャッジ時間 13,667 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 59 ms
18,924 KB
testcase_01 AC 60 ms
22,964 KB
testcase_02 AC 62 ms
22,960 KB
testcase_03 AC 60 ms
21,104 KB
testcase_04 AC 59 ms
20,964 KB
testcase_05 AC 60 ms
20,972 KB
testcase_06 AC 60 ms
20,872 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 60 ms
20,904 KB
testcase_10 WA -
testcase_11 AC 83 ms
27,172 KB
testcase_12 AC 67 ms
22,992 KB
testcase_13 AC 60 ms
20,884 KB
testcase_14 AC 60 ms
20,904 KB
testcase_15 AC 60 ms
20,972 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 TLE -
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;
		
		Dictionary<ATMTN,int> D=new Dictionary<ATMTN,int>();
		D.Add(new ATMTN(0,0,0,0,0),0);
		
		for(int n=0;n<N;n++){
//Console.WriteLine("n={0}",n);
//foreach(var k in D.Keys)Console.WriteLine("\t{0},{1},{2},{3},{4}",k.K,k.U,k.R,k.O,k.I);
			Dictionary<ATMTN,int> Dnxt=new Dictionary<ATMTN,int>();
			switch(S[n]){
				case 'K':
					foreach(var a in D.Keys){
						var anew=new ATMTN(a);
						anew.K++;
						if(!Dnxt.ContainsKey(anew))Dnxt.Add(anew,0);
						Dnxt[anew]=Math.Max(Dnxt[anew],D[a]);
					}
					break;
				case 'U':
					foreach(var a in D.Keys){
						var anew=new ATMTN(a);
						if(anew.K>0){anew.U++;anew.K--;
							if(!Dnxt.ContainsKey(anew))Dnxt.Add(anew,0);
							Dnxt[anew]=Math.Max(Dnxt[anew],D[a]);
						}
					}
					break;
				case 'R':
					foreach(var a in D.Keys){
						var anew=new ATMTN(a);
						if(anew.U>0){anew.R++;anew.U--;
							if(!Dnxt.ContainsKey(anew))Dnxt.Add(anew,0);
							Dnxt[anew]=Math.Max(Dnxt[anew],D[a]);
						}
					}
					break;
				case 'O':
					foreach(var a in D.Keys){
						var anew=new ATMTN(a);
						if(anew.R>0){anew.O++;anew.R--;
							if(!Dnxt.ContainsKey(anew))Dnxt.Add(anew,0);
							Dnxt[anew]=Math.Max(Dnxt[anew],D[a]);
						}
					}
					break;
				case 'I':
					foreach(var a in D.Keys){
						var anew=new ATMTN(a);
						if(anew.O>0){anew.I++;anew.O--;
							if(!Dnxt.ContainsKey(anew))Dnxt.Add(anew,0);
							Dnxt[anew]=Math.Max(Dnxt[anew],D[a]);
						}
					}
					break;
				case '?':
					foreach(var a in D.Keys){
						var anew=new ATMTN(a);
						anew.K++;
						if(!Dnxt.ContainsKey(anew))Dnxt.Add(anew,0);
						Dnxt[anew]=Math.Max(Dnxt[anew],D[a]);
						
						anew=new ATMTN(a);
						if(anew.K>0){anew.U++;anew.K--;
							if(!Dnxt.ContainsKey(anew))Dnxt.Add(anew,0);
							Dnxt[anew]=Math.Max(Dnxt[anew],D[a]);
						}
						
						anew=new ATMTN(a);
						if(anew.U>0){anew.R++;anew.U--;
							if(!Dnxt.ContainsKey(anew))Dnxt.Add(anew,0);
							Dnxt[anew]=Math.Max(Dnxt[anew],D[a]);
						}
						
						anew=new ATMTN(a);
						if(anew.R>0){anew.O++;anew.R--;
							if(!Dnxt.ContainsKey(anew))Dnxt.Add(anew,0);
							Dnxt[anew]=Math.Max(Dnxt[anew],D[a]);
						}
						
						anew=new ATMTN(a);
						if(anew.O>0){anew.I++;anew.O--;
							if(!Dnxt.ContainsKey(anew))Dnxt.Add(anew,0);
							Dnxt[anew]=Math.Max(Dnxt[anew],D[a]);
						}
					}
					break;
		
				default:
					foreach(var kvp in D)Dnxt.Add(kvp.Key,kvp.Value);
					break;
		
			}
			D=Dnxt;
		}
		
		int ans=0;
		foreach(var k in D.Keys){
			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