Program.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //#define PRINT
  2. using D24._1;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.IO;
  6. using System.Linq;
  7. namespace D24._2
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. if (args.Length < 1) return;
  14. if (File.Exists(args[0]) == false) return;
  15. List<Group> all;
  16. Dictionary<string, int> teams;
  17. Dictionary<string, int> origTeams = new Dictionary<string, int>();
  18. _1.Program.ParseFile(args, out all, out teams);
  19. foreach (var team in teams) origTeams.Add(team.Key, team.Value);
  20. int bonus = 2;
  21. string bonusTeam = "Immune System";
  22. do
  23. {
  24. #if PRINT == false
  25. Console.Write($"Trying with a boost of : {bonus}\r");
  26. #endif
  27. SystemCleanup(all, teams, origTeams, bonus, bonusTeam);
  28. while (teams.All(t => t.Value > 0))
  29. {
  30. _1.Program.TargetSelectionPhase(all);
  31. bool deadlock = _1.Program.AttackPhase(all, teams) == false;
  32. if (deadlock) break;
  33. }
  34. if (teams.Where(t => t.Key != bonusTeam).Sum(t => t.Value) > 0) bonus++; else break;
  35. } while (true);
  36. int answer = all.Sum(a => a.Number);
  37. Console.WriteLine($"\nThe answer is : {answer}");
  38. }
  39. private static void SystemCleanup(List<Group> all, Dictionary<string, int> teams, Dictionary<string, int> origTeams, int bonus, string bonusTeam)
  40. {
  41. foreach (var team in origTeams)
  42. teams[team.Key] = origTeams[team.Key];
  43. foreach (var group in all)
  44. {
  45. group.Number = group.OrigNumber;
  46. group.Healthy = true;
  47. if (group.Team != bonusTeam) continue;
  48. group.AtkBonus = bonus;
  49. }
  50. }
  51. }
  52. }