UOFTBD - Diablo Bot

no tags 

Maybe you've played Diablo? There are three different character classes: Noobs, Suckers, and Pros. Noobs don't know anything about the game. Suckers think they know how to play. Pros know that the goal of the game is to write a script that will farm for valuable items that they can turn around and sell to Suckers on the black market. Obviously Pros would sell to Noobs if they could, but Noobs don't even know how to buy items.

An obvious piece of prerequisite information for making such a bot is knowing what sorts of items are worth picking up. There are Normal, Magic, Rare, and Set items:

  • Set items always belong to some famous dead person, so they always begin with a word that ends in "'s" (e.g. Andrew's). No other items are special enough to begin this way.
  • Rare items always have names that are two words long.
  • Magic items always have names that are between two and four words long, inclusive. If, and only if, a Magic item has more than two words in its name, then the last two words are "of [something]" (e.g. of Doom).
  • If the first word is "Damaged", the item is a Normal item. Furthermore, any item that could not possibly be Magic, Rare, or Set must also be Normal. No other items are Normal.
  • You may not have played Diablo, but hopefully you still know that a "word" is a maximal substring of non-space characters. Also, letter case is irrelevant.

You have a list of $N$ ($1 \leq N \leq 1000$) item names, and you need to be able to classify these items as accurately as possible. It may not be possible to assign a unique type to each item, but as long as it's not Normal, surely you'll want it. Every item name is a string of no more than 100 characters, containing only alphabetic characters, spaces, and apostrophes. Every name begins and ends with a non-space character.

Input

First line: 1 integer, $N$

Next $N$ lines: The name of the $i$th item, for $i = 1..N$

Output

$N$ lines: The type of the $i$th item (one of "Normal", "Set", "Magic", or "Rare"), or "Not sure, take anyways" (without quotes) if the item's type cannot be determined, but is known not to be Normal, for $i = 1..N$

Example

Input:
7
Somebody's Something of Whatever
stone of jordan
Wirt's Leg
FLAMING TURNIP
Damaged Goods
Sword
Fish shaped volatile organic compounds
Output: Set
Magic
Set
Not sure, take anyways
Normal
Normal
Normal
 

Explanation of Sample:

The first and third items begin with possessives, so they must be Set items. The second item is three words long, and ends in "of [something]" so it must be Magic. The fourth item could be either Rare or Magic. The fifth item begins with "Damaged" so it's Normal. The last two items don't fit the descriptions of Set, Rare, or Magic, so they must be Normal also.


hide comments
Sushovan Sen: 2021-11-01 11:33:32

I'm not a native English speaker. All wrong answers were due to not paying attention to details.

:D: 2021-03-28 22:53:07

I'll put clarifications here that I feel are warranted, but do not spoil anything.

1) "Set" first word must end with " 's " (with apostrophe) and not just " s "
2) Damaged of [something] is classified as "Normal"

Other than that I think the description is unambiguous, maybe just a little tricky. Good problem.

nadstratosfer: 2019-12-25 02:11:34

Got the logic almost right the first time around and fixed the problem quickly, but it took almost an hour to find out it was the implementation of my fix that was wrong.

Those confused by iff, check https://en.wikipedia.org/wiki/If_and_only_if , especially the first line and the truth table. Also, letter case not being relevant means handling it is ;)

darol: 2015-02-08 16:07:04

Finally, stupid mistake costed me few WA. "if, and only if" part was critical for me.

Abhinav: 2014-12-18 12:19:40

If the first word is "Damaged", the item is a Normal item. Furthermore, any item that could not possibly be Magic, Rare, or Set must also be Normal. No other items are Normal.
@Jacob Plachta
how come sword is normal ?

RE: Read the problem more carefully.

Last edit: 2015-01-01 04:47:04
Miguel Oliveira: 2013-07-18 00:21:17

I'm not a native english speaker. I don't like problems where part of the difficulty is interpreting the statement.
The "if, and only if" part is not clear to me. I got it accepted with the hints in the forum.

RE: "If and only if" is a well-known type of statement in logic, with a single interpretation. But it is easy to not be careful enough.

Last edit: 2013-07-21 08:36:36
Eduardo Nunes: 2013-06-13 19:56:37

wow, that is a nice problem... after a naive attempt, took me a week re-reading description and comments... phew, finally found it... :-)

Haijun Deng: 2013-06-13 14:34:33

And what's for "damaged aa of bb"?

RE: All required information can be found in the problem statement - careful reading is required.

Last edit: 2013-06-13 18:31:26
P[_]/|/K: 2013-06-12 09:59:11

Nice question!!
Read carefully..


Added by:SourSpinach
Date:2013-05-17
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:Written by Wesley May, used in the 2012 UofT ACM Tryouts