diff --git a/2024ProconTemporary/Command-Line/BootCommand.cs b/2024ProconTemporary/Command-Line/BootCommand.cs index 84a0be4..87ce551 100644 --- a/2024ProconTemporary/Command-Line/BootCommand.cs +++ b/2024ProconTemporary/Command-Line/BootCommand.cs @@ -68,7 +68,7 @@ public void Handle(BootCommandClient args) Console.WriteLine("Automatic Mode"); Console.WriteLine("Calculating Answer..."); // ここで問題データをMainAlgorithmに渡して、回答を計算する(引数はReadableProblemData型) - MainAlgorithm.MatchCalculate(); + // Mainalgorithm.MatchCalculate(); Console.WriteLine("Done!"); diff --git a/2024ProconTemporary/Command-Line/BootProgram.cs b/2024ProconTemporary/Command-Line/BootProgram.cs index 39cca61..b28352d 100644 --- a/2024ProconTemporary/Command-Line/BootProgram.cs +++ b/2024ProconTemporary/Command-Line/BootProgram.cs @@ -8,8 +8,8 @@ class BootProgram { - static void Main(string[] args) - { - Cli.Execute(args); - } + // static void Main(string[] args) + // { + // Cli.Execute(args); + // } } \ No newline at end of file diff --git a/2024ProconTemporary/MainAlgorithm.cs b/2024ProconTemporary/MainAlgorithm.cs index e58d328..0debb98 100644 --- a/2024ProconTemporary/MainAlgorithm.cs +++ b/2024ProconTemporary/MainAlgorithm.cs @@ -1,6 +1,8 @@ using _2024ProconTemporary.Com; +using _2024ProconTemporary.ReadableData; using System; +using System.ComponentModel.DataAnnotations; using System.IO; using System.Runtime.InteropServices; using System.Text; @@ -10,7 +12,7 @@ namespace _2024ProconTemporary public class Mainalgorithm { - + Case cases = new Case(); Practice practice = new Practice(); Pattern Pattern = new Pattern(); @@ -35,15 +37,15 @@ public static void Main() Hyoji(Practice.QuesTes2); //Practice.QuesTes = QuestionShunting(Practice.QuesTes2,Practice.AnsTes2); // Console.WriteLine(""); - for(int i = 0; i < 1; i++) + for (int i = 0; i < 1; i++) { IndexCount(Practice.QuesTes2); MainTest(Practice.QuesTes2, Practice.AnsTes2, 0); } - + } - public AnswerData Calculation(ProblemData problemData) + public AnswerData Calculation(ProblemData problemData) { Pattern.Patterns(); Practice.Practices(); @@ -58,8 +60,8 @@ public AnswerData Calculation(ProblemData problemData) } return new AnswerData { - N = 0, - Ops = new List() + N = 0, + Ops = new List() }; } public static void Hyoji(List> Ans) @@ -109,7 +111,7 @@ public static List> QuestionShunting(List> Ques, List MaxZeroCount) { MaxZeroCount = ZeroCount; @@ -205,8 +207,8 @@ public static List> MainTest(List> Ques, List> Ans WantIndex[0].Add(new List()); WantIndex[0][Y] = Search(Ques, Ans, WantIndex[0][Y], 1, Y); WantIndex[1].Add(new List()); - WantIndex[1][Y] = Search(Ques, Ans, WantIndex[1][Y], WantIndex[0][Y].Count + 2, Y); - NextSearch(Ques, Ans, WantIndex, WantIndex[0][Y].Count + WantIndex[1][Y].Count + 2, Y); + WantIndex[1][Y] = Search(Ques, Ans, WantIndex[1][Y], WantIndex[0][Y].Count + 2, Y); + NextSearch(Ques, Ans, WantIndex, WantIndex[0][Y].Count + WantIndex[1][Y].Count + 2, Y); } @@ -267,7 +269,7 @@ public static List NextSearch(List> Ques, List> Ans, Li } break; } - if(i== 1) + if (i == 1) { ques[Y].RemoveAt(QuesNumberIndex); } @@ -307,7 +309,7 @@ public static void EvaluationValue(List> Ques, List> Ans, Li } public static void Check(List> Ques, List> Ans, List>> WantTypeIndex) { - + } public static void Overcalculation(List> Ques, List> Ans, List>> WantTypeIndex) @@ -374,5 +376,86 @@ public static void IndexCount(List> Ques) } + /// + /// 列ごとを揃えたあとに、行ごとで揃えるために必要な型の種類と抜く座標を返す + /// + public (int, int, int, int) SearchDie(ReadableProblemData problemData, List> ques, List> ans) + { + int useDieNum = 0; + int cuttingDirection = 0; + int usingPositionX = 0; + int usingPositionY = 0; + int nowMaxEffectiveScore = 0; + List> collectPieceArray = CreateCollectPieceArray(ques, ans); + + // 仕様メモ + // 左端、もしくは右端を固定し、一方向にしか動かないようにする + // for文を回して、どの型が一番効率的かを計算する + // 効率的かどうかは、(揃ったピースの数-揃わなくなったピースの数)で判断する + // 効率的なものを見つけたら、使うべき型、使うべき座標を返す + + for (int useDieIndex = 0; useDieIndex < problemData.General.Patterns.Count; useDieIndex++) + { + for (int x = 0; x < Xmax; x++) + { + for (int y = 0; y < Ymax; y++) + { + int rightCuttingEffectiveScore; + int leftCuttingEffectiveScore; + List> tempQues = Case.Copy(ques); + List> tempAns = Case.Copy(ans); + List> leftCuttingQues = Case.DieCuttingLeft(tempQues, Pattern.PatternList[useDieIndex], y, x, Pattern.PatternList[useDieIndex].GetLength(1), Pattern.PatternList[useDieIndex].GetLength(0)); + List> rightCuttingQues = Case.DieCuttingRight(tempQues, Pattern.PatternList[useDieIndex], y, x, Pattern.PatternList[useDieIndex].GetLength(1), Pattern.PatternList[useDieIndex].GetLength(0)); + + List> leftCuttingCollectPieceArray = CreateCollectPieceArray(leftCuttingQues, tempAns); + List> rightCuttingCollectPieceArray = CreateCollectPieceArray(rightCuttingQues, tempAns); + + rightCuttingEffectiveScore = CalculateEffectiveScore(collectPieceArray, rightCuttingCollectPieceArray); + leftCuttingEffectiveScore = CalculateEffectiveScore(collectPieceArray, leftCuttingCollectPieceArray); + + if (MathF.Max(rightCuttingEffectiveScore, leftCuttingEffectiveScore) > nowMaxEffectiveScore) + { + nowMaxEffectiveScore = (int)MathF.Max(rightCuttingEffectiveScore, leftCuttingEffectiveScore); + useDieNum = useDieIndex; + usingPositionX = x; + usingPositionY = y; + } + } + } + } + + return (useDieNum, cuttingDirection, usingPositionX, usingPositionY); + + } + + int CalculateEffectiveScore(List> beforeCollectPieceArray, List> afterCollectPieceArray) + { + int effectiveScore = 0; + for (int y = 0; y < Ymax; y++) + { + for (int x = 0; x < Xmax; x++) + { + effectiveScore += (int)beforeCollectPieceArray[y][x] - afterCollectPieceArray[y][x] + } + } + return effectiveScore; + } + + List> CreateCollectPieceArray(List> ques, List> ans) + { + List> collectPieceArray = new List>(); + for (int x = 0; x < Xmax; x++) + { + List collectPieceRaw = new List(); + for (int y = 0; y < Ymax; y++) + { + if (ques[y][x] == ans[y][x]) collectPieceRaw.Add(1); + else collectPieceRaw.Add(0); + } + collectPieceArray.Add(collectPieceRaw); + } + return collectPieceArray; + } + } -} +} \ No newline at end of file diff --git a/2024ProconTemporary/obj/Debug/net8.0/2024ProconTemporary.AssemblyInfo.cs b/2024ProconTemporary/obj/Debug/net8.0/2024ProconTemporary.AssemblyInfo.cs index fb888c5..b99a6ed 100644 --- a/2024ProconTemporary/obj/Debug/net8.0/2024ProconTemporary.AssemblyInfo.cs +++ b/2024ProconTemporary/obj/Debug/net8.0/2024ProconTemporary.AssemblyInfo.cs @@ -1,10 +1,9 @@ //------------------------------------------------------------------------------ // -// このコードはツールによって生成されました。 -// ランタイム バージョン:4.0.30319.42000 +// This code was generated by a tool. // -// このファイルへの変更は、以下の状況下で不正な動作の原因になったり、 -// コードが再生成されるときに損失したりします。 +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. // //------------------------------------------------------------------------------ @@ -14,7 +13,7 @@ [assembly: System.Reflection.AssemblyCompanyAttribute("2024ProconTemporary")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+2224d9788438e09a2f66a1a6df3af58463175128")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+4f25c213b0eb164023b5c8f8e1793b8e4b3f20db")] [assembly: System.Reflection.AssemblyProductAttribute("2024ProconTemporary")] [assembly: System.Reflection.AssemblyTitleAttribute("2024ProconTemporary")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/2024ProconTemporary/obj/Debug/net8.0/2024ProconTemporary.AssemblyInfoInputs.cache b/2024ProconTemporary/obj/Debug/net8.0/2024ProconTemporary.AssemblyInfoInputs.cache index 473f42e..e9f6849 100644 --- a/2024ProconTemporary/obj/Debug/net8.0/2024ProconTemporary.AssemblyInfoInputs.cache +++ b/2024ProconTemporary/obj/Debug/net8.0/2024ProconTemporary.AssemblyInfoInputs.cache @@ -1 +1 @@ -86fc78adfc98c6fc3e798c758dda2f99f1413c0aab3cec7018efd1cad9520e83 +54f31958582c1b29d9a118743e8f8ecb03604e4feeca0f0616ed1621828e6d64