| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- //#define PRINT
- using D24._1;
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- namespace D24._2
- {
- class Program
- {
- static void Main(string[] args)
- {
- if (args.Length < 1) return;
- if (File.Exists(args[0]) == false) return;
- List<Group> all;
- Dictionary<string, int> teams;
- Dictionary<string, int> origTeams = new Dictionary<string, int>();
- _1.Program.ParseFile(args, out all, out teams);
- foreach (var team in teams) origTeams.Add(team.Key, team.Value);
- int bonus = 2;
- string bonusTeam = "Immune System";
- do
- {
- #if PRINT == false
- Console.Write($"Trying with a boost of : {bonus}\r");
- #endif
- SystemCleanup(all, teams, origTeams, bonus, bonusTeam);
- while (teams.All(t => t.Value > 0))
- {
- _1.Program.TargetSelectionPhase(all);
- bool deadlock = _1.Program.AttackPhase(all, teams) == false;
- if (deadlock) break;
- }
- if (teams.Where(t => t.Key != bonusTeam).Sum(t => t.Value) > 0) bonus++; else break;
- } while (true);
- int answer = all.Sum(a => a.Number);
- Console.WriteLine($"\nThe answer is : {answer}");
- }
- private static void SystemCleanup(List<Group> all, Dictionary<string, int> teams, Dictionary<string, int> origTeams, int bonus, string bonusTeam)
- {
- foreach (var team in origTeams)
- teams[team.Key] = origTeams[team.Key];
- foreach (var group in all)
- {
- group.Number = group.OrigNumber;
- group.Healthy = true;
- if (group.Team != bonusTeam) continue;
- group.AtkBonus = bonus;
- }
- }
- }
- }
|