ARMY - Army Strength

no tags 

The next MechaGodzilla invasion is on its way to Earth. And once again, Earth will be the battleground for an epic war.

MechaGodzilla's army consists of many nasty alien monsters, such as Space Godzilla, King Gidorah, and MechaGodzilla herself.

To stop them and defend Earth, Godzilla and her friends are preparing for the battle.

Problem specification

Each army consists of many different monsters. Each monster has a strength that can be described by a positive integer. (The larger the value, the stronger the monster.)

The war will consist of a series of battles. In each battle, the weakest of all the monsters that are still alive is killed.

If there are several weakest monsters, but all of them in the same army, one of them is killed at random. If both armies have at least one of the weakest monsters, a random weakest monster of MechaGodzilla's army is killed.

The war is over if in one of the armies all monsters are dead. The dead army lost, the other one won.

You are given the strengths of all the monsters. Find out who wins the war.

Input specification

The first line of the input file contains an integer T specifying the number of test cases. Each test case is preceded by a blank line.

Each test case starts with line containing two positive integers NG and NM – the number of monsters in Godzilla's and in MechaGodzilla's army. Two lines follow. The first one contains NG positive integers – the strengths of the monsters in Godzilla's army. Similarly, the second one contains NM positive integers – the strengths of the monsters in MechaGodzilla's army.

Output specification

For each test case, output a single line with a string that describes the outcome of the battle.

If it is sure that Godzilla's army wins, output the string "Godzilla".

If it is sure that MechaGodzilla's army wins, output the string "MechaGodzilla".

Otherwise, output the string "uncertain".



1 1

3 2
1 3 2
5 5



In the first test case, there are only two monsters, and they are equally strong. In this situation, MechaGodzilla's monster is killed and the war ends.

In the second test case, the war will consist of three battles, and in each of them one of Godzilla's monsters dies.

For all the test cases, int in C/C++/Java or longint in Pascal is enough.

hide comments
flower: 2023-07-22 09:58:04

The absence of limits for "NG" and "NM" is, in itself, a hint for the O(n) solution.

akihisa: 2021-12-21 23:12:29

For the first time, I got AC in one go. Happy. :D

manurag_20: 2021-10-19 22:44:21

nothing to do with "uncertain". Simple problem. Don't overthink.

guru_shreyansh: 2021-08-28 12:33:05

Done! 3 lines of code in Python!! No sorting or queue.

darkdeveloper: 2021-07-13 18:31:35

it will never be uncertain :)

loser_404: 2021-06-05 06:15:34

AC in one go

the_art_maniac: 2021-05-29 17:34:26

if all numbers are positive then what will be an uncertain case?

yasser1110: 2021-02-24 12:59:56

O(nlogn) solution gets the job done, but O(n) solution is possible

tejasreddyk: 2021-01-14 16:27:13

Bruh! AC in one go ;-;

varuntumbe: 2020-09-13 09:10:15

uncertain was really unnecessary

Added by:Fudan University Problem Setters
Time limit:0.5s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: C99 ERL JS-RHINO NODEJS PERL6 VB.NET
Resource:IPSC 2008