P28192 [洛谷] yyy loves Easter_Egg I
普及+
题目描述

Problem Background

Soha's problem-setting efficiency is truly astonishing. Problems for OI, Math, and Chemistry have all been prepared, but not a single one for Physics. Therefore, Huntfire, absi2011, and redbag take turns bombarding soha, intending to force him out. Unexpectedly, kkksc03 bursts out from the crowd...

Problem Description

yyy loves OI (Huntfire), yyy loves Maths (redbag), and yyy loves Chemistry (absi2011) take turns bombarding yyy loves Physics (soha). The order of the bombardment is Huntfire, redbag, absi2011.

In this problem, we do not consider overly complex formations. We consider a formation valid if a message contains exactly one "@" and the person being mentioned is the same as in the previous message.

For example, the following is also considered a formation:

  • yyy loves OI : @yyy loves Microelectronic
  • yyy loves Maths : @yyy loves Microelectronic I admire soha's problem-setting efficiency
  • yyy loves OI : @yyy loves Microelectronic +1
  • yyy loves Chemistry : +1 @yyy loves Microelectronic

If the person mentioned with "@" is different from the first person, the formation is broken. If someone speaks up before the formation is broken, or if they break the formation themselves, the bombardment is considered successful.

If the bombardment is successful, output Successful @某某某 attempt. If the formation is broken, first output Unsuccessful @某某某 attempt, then output the line number where the formation was first broken and the ID of the person who broke the formation.

If the formation is never broken, first output Unsuccessful @某某某 attempt, then output the length of the formation, and finally output Good Queue Shape.

p.s. yyy loves Microelectronic is kkksc03

Input Format

$N$ lines, each representing a message after the bombardment begins. Each message is in the format: "Sender: Message content", with each line not exceeding 1000 characters. (Chinese words are replaced with pinyin)

Output Format

If the bombardment is successful, output Successful @某某某 attempt. If the formation is broken, first output Unsuccessful @某某某 attempt, then output the line number where the formation was first broken, and the ID of the person who broke the formation.

If the formation is never broken, first output Unsuccessful @某某某 attempt, then output the length of the formation, and finally output Good Queue Shape.

Sample Input and Output

Input Sample #1

yyy loves OI : @yyy loves Physics I admire your problem-setting efficiency
yyy loves Maths : @yyy loves Physics I admire your problem-setting efficiency
yyy loves Chemistry : @yyy loves Physics I admire your problem-setting efficiency
yyy loves Microelectronic : are you guys bored yet
yyy loves OI : @yyy loves Physics I admire your problem-setting efficiency

Output Sample #1

Unsuccessful @yyy loves Physics attempt
4
yyy loves Microelectronic

Input Sample #2

yyy loves OI : @yyy loves Physics I admire your problem-setting efficiency
yyy loves Maths : @yyy loves Physics I admire your problem-setting efficiency
yyy loves Chemistry : @yyy loves Physics I admire your problem-setting efficiency
yyy loves OI : @yyy loves Physics I admire your problem-setting efficiency
yyy loves Maths : @yyy loves Physics I admire your problem-setting efficiency
yyy loves Chemistry : @yyy loves Physics I admire your problem-setting efficiency
yyy loves OI : @yyy loves Physics I admire your problem-setting efficiency
yyy loves Maths : @yyy loves Physics I admire your problem-setting efficiency
yyy loves Chemistry : @yyy loves Physics I admire your problem-setting efficiency
yyy loves Physics : you guys are enough

Output Sample #2

Successful @yyy loves Physics attempt

Notes

@yyy loves Physics I admire your problem-setting efficiency

This problem is just a吐槽 about soha, commemorating the problem-setter's formation, which lasted 91 lines.

For 100% of the data, each message length $\le 10^3$.

  • The number of lines is guaranteed to be no more than $5 \times 10^4$;
  • The input file size is guaranteed to be no more than 4MB;
  • The first speaker is guaranteed to mention someone with exactly one "@";
  • Everyone's name is guaranteed to be in the format "yyy loves ***";
  • Guaranteed that no one's message contains a colon (:);
  • The first speaker is guaranteed to mention someone and only one person;
  • The first speaker is guaranteed not to mention themselves;
  • The file ends with a blank line to help you determine the end of the file;
  • It is not guaranteed how many people are mentioned in subsequent messages, but mentioning more than one person is considered breaking the formation;
  • It is not guaranteed that the mentioned person will necessarily break the formation;
  • It is not guaranteed that this problem is or is not the last problem;
  • It is not guaranteed that this set of competitions has a last problem;
  • It is not guaranteed that the next set of competitions will be as easy as this one;
  • It is not guaranteed that there are only these 4 people and kkksc03 in the group;
  • It is not guaranteed that complaining about soha without ACing this problem will be fine;
  • ACing this problem allows you to complain about soha once, and soha won't mind.
输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
yyy loves OI : @yyy loves Physics wo pei fu ni de chu ti xiao lv yyy loves Maths : @yyy loves Physics wo pei fu ni de chu ti xiao lv yyy loves Chemistry : @yyy loves Physics wo pei fu ni de chu ti xiao lv yyy loves Microelectronic : ni men wu liao me yyy loves OI : @yyy loves Physics wo pei fu ni de chu ti xiao lv
样例输出
Unsuccessful @yyy loves Physics attempt 4 yyy loves Microelectronic