LCC/Moose '20 Contest 3 J2 - Tracy and Big Mac(beth)

View as PDF

Submit solution

Points: 3 (partial)
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

Tracy is struggling with her English assignment on Big Macs. She wants to rank each of the N Big Macs numbered 1 \ldots N she has to determine which to write about in her assignment. She decides to score a Big Mac based on the following criteria:

  1. +1 if the Big Mac starts with bun
  2. +1 if the Big Mac ends with bun
  3. -1 for each bun anywhere besides the start or end of the Big Mac
  4. +1 for each meat before the first cheese, or +1 for each meat if there is no cheese
  5. +1 if the Big Mac contains sauce
  6. +1 for each pickle
  7. -1 for each feces or rat

Given the arrangements of each of her Big Macs, can you output the index of the Big Mac with the greatest score?

Input Specification

The first line will contain a single integer N (1 \leq N \leq 10^3), the number of Big Macs she has.

The next N lines will contain a single integer M (1 \leq M \leq 10^3) followed by M Big Mac ingredients, separated by spaces. Each Big Mac ingredient will be a single character b, m, c, s, p, f, r, representing bun, meat, cheese, sauce, pickle, feces, and rat, respectively.

Output Specification

Output a single integer, the index of the Big Mac with the greatest score. If there are multiple Big Macs, output the Big Mac with the smallest index.

Sample Input 1

3
6 b f f f f b
4 p p p p
1 b

Sample Output 1

2

Explanation for Sample 1

The first Big Mac has a score of 1+1-1-1-1-1 = -2. The second Big Mac has a score of 1+1+1+1 = 4. The last Big Mac has a score of 1+1 = 2. As such, the second Big Mac has the highest score.

Sample Input 2

3
1 f
3 r b r
1 r

Sample Output 2

1

Comments

There are no comments at the moment.