結果
| 問題 |
No.233 めぐるはめぐる (3)
|
| コンテスト | |
| ユーザー |
14番
|
| 提出日時 | 2016-05-08 00:29:37 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 4,506 bytes |
| コンパイル時間 | 2,290 ms |
| コンパイル使用メモリ | 114,676 KB |
| 実行使用メモリ | 127,812 KB |
| 最終ジャッジ日時 | 2024-10-05 10:30:53 |
| 合計ジャッジ時間 | 7,798 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 4 WA * 7 |
コンパイルメッセージ
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.Generic;
class Program
{
public void Proc()
{
Reader.IsDebug = false;
string targetstr = "inabameguru";
int inputCount =int.Parse( Reader.ReadLine());
for (int i=0; i<inputCount; i++) {
this.NGList.Add(Reader.ReadLine());
}
List<char> boin = new List<char>();
List<char> shiin = new List<char>();
List<char> boinList = new List<char>( new char[]{'a', 'i','u','e','o'});
for(int i=0; i<targetstr.Length; i++) {
char c = targetstr[i];
if(boinList.Contains(c)) {
boin.Add(targetstr[i]);
} else
{
shiin.Add(targetstr[i]);
}
}
List<string> list = this.getAns(boin, shiin, true, string.Empty);
}
private bool MustQuit = false;
private Dictionary<string, Dictionary<string, Dictionary<bool, List<string>>>> dic = new Dictionary<string, Dictionary<string, Dictionary<bool, List<string>>>>();
private List<string> getAns(List<char> boin, List<char> shiin, bool isPrevBoin, string totyu) {
string keyBoin = string.Join("", boin);
string keyShiin = string.Join("", shiin);
if(!dic.ContainsKey(keyBoin)) {
dic.Add(keyBoin, new Dictionary<string, Dictionary<bool, List<string>>>());
}
if(!dic[keyBoin].ContainsKey(keyShiin)) {
dic[keyBoin].Add(keyShiin,new Dictionary<bool, List<string>>());
}
if(dic[keyBoin][keyShiin].ContainsKey(isPrevBoin)) {
return dic[keyBoin][keyShiin][isPrevBoin];
}
List<string> ans = new List<string>();
if(MustQuit) {
return ans;
}
if(boin.Count == 1 && shiin.Count == 0) {
string ret = totyu + boin[0];
if(!NGList.Contains(ret)) {
Console.WriteLine(ret);
MustQuit = true;
return ans;
}
ans.Add(boin[0].ToString());
} else if(boin.Count == 0 && shiin.Count > 0) {
} else if(shiin.Count > boin.Count) {
} else
{
for(int i=0; i<boin.Count; i++) {
List<char> subBoin = new List<char>(boin);
subBoin.RemoveAt(i);
List<string> ret = this.getAns(subBoin, shiin, true, totyu + boin[i]);
if(ret.Count > 0) {
ret.ForEach(a=>ans.Add(boin[i] + a));
}
if(MustQuit) {
return ans;
}
}
if(isPrevBoin) {
for(int i=0; i<shiin.Count; i++) {
List<char> subShin = new List<char>(shiin);
subShin.RemoveAt(i);
List<string> ret = this.getAns(boin, subShin, false, totyu +shiin[i]);
if(ret.Count > 0) {
ret.ForEach(a=>ans.Add(shiin[i] + a));
}
if(MustQuit) {
return ans;
}
}
}
}
this.dic[keyBoin][keyShiin].Add(isPrevBoin, ans);
return ans;
}
private List<string> NGList = new List<string>();
public class Reader
{
public static bool IsDebug = true;
private static String PlainInput = @"
3
inabameguru
meguruinaba
nemuriugaba
";
private static System.IO.StringReader Sr = null;
public static string ReadLine()
{
if (IsDebug)
{
if (Sr == null)
{
Sr = new System.IO.StringReader(PlainInput.Trim());
}
return Sr.ReadLine();
}
else
{
return Console.ReadLine();
}
}
public static int[] GetInt(char delimiter = ' ', bool trim = false)
{
string inptStr = ReadLine();
if (trim)
{
inptStr = inptStr.Trim();
}
string[] inpt = inptStr.Split(delimiter);
int[] ret = new int[inpt.Length];
for (int i = 0; i < inpt.Length; i++)
{
ret[i] = int.Parse(inpt[i]);
}
return ret;
}
}
static void Main()
{
Program prg = new Program();
prg.Proc();
}
}
14番