結果

問題 No.291 黒い文字列
ユーザー kuuso1kuuso1
提出日時 2015-10-17 11:08:10
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 2,720 bytes
コンパイル時間 3,261 ms
コンパイル使用メモリ 111,856 KB
実行使用メモリ 46,944 KB
最終ジャッジ日時 2023-09-29 15:58:21
合計ジャッジ時間 12,176 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
25,300 KB
testcase_01 AC 69 ms
24,612 KB
testcase_02 WA -
testcase_03 AC 89 ms
28,544 KB
testcase_04 AC 70 ms
24,684 KB
testcase_05 WA -
testcase_06 AC 102 ms
30,848 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 66 ms
25,744 KB
testcase_10 WA -
testcase_11 AC 144 ms
37,864 KB
testcase_12 AC 150 ms
41,816 KB
testcase_13 AC 71 ms
24,564 KB
testcase_14 AC 109 ms
32,212 KB
testcase_15 AC 92 ms
30,392 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 516 ms
44,872 KB
testcase_24 WA -
testcase_25 RE -
testcase_26 AC 463 ms
44,880 KB
testcase_27 WA -
testcase_28 RE -
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;
		int[,,,] dp=new int[21,21,21,21];
		for(int i=0;i<21;i++){
			for(int j=0;j<21;j++){
				for(int k=0;k<21;k++){
					for(int l=0;l<21;l++){
						dp[i,j,k,l]=-1;
					}
				}
			}
		}
		dp[0,0,0,0]=0;
		for(int c=0;c<N;c++){
			int[,,,] dnxt=new int[21,21,21,21];
			for(int i=0;i<21;i++){
				for(int j=0;j<21;j++){
					for(int k=0;k<21;k++){
						for(int l=0;l<21;l++){
							dnxt[i,j,k,l]=-1;
						}
					}
				}
			}
			for(int i=0;i<21;i++){
				for(int j=0;j<21;j++){
					for(int k=0;k<21;k++){
						for(int l=0;l<21;l++){
							if(dp[i,j,k,l]==-1)continue;
							switch(S[c]){
								case 'K':if(i+1<21)dnxt[i+1,j,k,l]=Math.Max(dnxt[i+1,j,k,l],dp[i,j,k,l]);break;
								case 'U':if(j+1<21&&i-1>=0)dnxt[i-1,j+1,k,l]=Math.Max(dnxt[i+1,j,k,l],dp[i,j,k,l]);break;
								case 'R':if(k+1<21&&j-1>=0)dnxt[i,j-1,k+1,l]=Math.Max(dnxt[i+1,j,k,l],dp[i,j,k,l]);break;
								case 'O':if(l+1<21&&k-1>=0)dnxt[i,j,k-1,l+1]=Math.Max(dnxt[i+1,j,k,l],dp[i,j,k,l]);break;
								case 'I':if(l-1>=0)dnxt[i,j,k,l-1]=Math.Max(dnxt[i+1,j,k,l],dp[i,j,k,l]+1);break;
								case '?':
									if(i+1<21)dnxt[i+1,j,k,l]=Math.Max(dnxt[i+1,j,k,l],dp[i,j,k,l]);
									if(j+1<21&&i-1>=0)dnxt[i-1,j+1,k,l]=Math.Max(dnxt[i-1,j+1,k,l],dp[i,j,k,l]);
									if(k+1<21&&j-1>=0)dnxt[i,j-1,k+1,l]=Math.Max(dnxt[i,j-1,k+1,l],dp[i,j,k,l]);
									if(l+1<21&&k-1>=0)dnxt[i,j,k-1,l+1]=Math.Max(dnxt[i,j,k-1,l+1],dp[i,j,k,l]);
									if(l-1>=0)dnxt[i,j,k,l-1]=Math.Max(dnxt[i,j,k,l-1],dp[i,j,k,l]+1);
									break;
								default:break;
							}
						}
					}
				}
			}
			dp=dnxt;
		}
		
		int max=0;
		foreach(var k in dp)max=Math.Max(max,k);
		Console.WriteLine(max);
		
		
	}
	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