Previous year ihack problem
— In the vibrant kingdom of Codeopia, ruled by the wise King Algorithmus, peace is maintained by the harmonious cooperation of its distinct clans. However, recent disturbances have threatened the stability of Codeopia, and King Algorithmus faces a daunting challenge Each clan, Cn, known for its skilled warriors, plays a crucial role in the kingdom's defense and prosperity. Out of all the clans that exists, there are only a few with abundance of natural resources. The clans without the natural resources relies on these clans for their supplies of armory and other ammun ition. Each such clan has the following attributes: Maximum Available Resource(MAR), which depicts the current maximum amount of resources available. It also depicts the maximum request of mining that a clan can hold. after which it won't accept any request unless it completely fulfils the existing ones. It will be re-filled once all the mining activities are done after RT seconds Processing Time per Resource(PTR), Which depicts the time(in secs) it takes to mine I amount Of resource Refill Time(RT), which depicts the refill time of the mine(in secs) NOTE: Each clan can mine the resources for only 1 recipient clan at any moment of time in whole numbers All the clans are connected through a road system, though not all of them are directly connected, Each road from clan Cl to C2 takes a fixed amount of time X to travel through it. There have been attacks on clans of Codeopia, and to safe-guard against each attack, the clan would need resources. To get the resources, the clan under attack will send its troops to get the resources from the clan which has the natural resources. Each attack has the following attributes: Attack Time(AT), which depicts the point of time(in secs) when the attack was launched on a certain clan Ci Resources Required (RR), which depicts the amount of resources it will take to counter this attack Gold Capturing Opportunity(GCO), which depicts the amount of gold that the clan Ci will receive after successfully countering the attack NOTE: Each clan can retrieve partial(in whole numbers) RR for which they can receive the partial(can be fractional) GCO. Though the time it takes for troops to travel back-and-forth will incur Can you help King Algorithmus in defending his kingdom against the foreign troops and maintaining prosperity by defeating the enemies in least amount of time and capturing maximum gold?
To simulate this situation, you'll have to process multiple Q(not-known upfront) queries of the following types: time) Process inputs # Process the starting information Of clans and their connectivity provided through XML Attack on Clam with X resources providing Y GCO Clanj has found natural resource's mine with X MAR, Y PTR and Z RT New Clanx has been formed, which has the connectivity to ClanA(with M time), Clans(with N time), Clanc(with O Clam has been blocked by enemies for X seconds # i.e., all paths leading to/from Clan, can't be accessed Show the current status Of all the clans with mines # i.e., show all the ongoing minest resources available Produce the current amount of Gold captured Victory of Codeopia # End of queries
Test Case :-
base_kingdom clan_a True 200 120 1 clan_b False clan_c False clan_c clan_a 20 clan_b clan_a 15
Queries :-
0: Process inputs 1: Attack on clan_b with 30 RR providing 15 GCO 6: Attack on clan_c with 70 RR providing 35 GCO 11: clan_a has been blocked by enemies for 30 seconds 30: Produce the current amount of Gold captured 61: Produce the current amount of Gold captured 95: Produce the current amount of Gold captured 100: Victory of Codeopia
Output :-
Gold captured: 0 Gold captured: 15 Gold captured: 35








PurpleCrayon helped me solve this problem, you can ask him!
Hwlp