13191319 SUSTech Online Judge
Problem 1319 --Lanrax

## 1319: Lanrax

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 2  Solved: 1
[Submit][Status][Web Board]

## Lanrax

One day, the people in the VCN Research Center wrote a paper, but VinceBlack did not want to use any existing reference format. Therefore, he came up with a new reference format called LANRAX. Now he wishes you to write a LANRAX format generator.

We describe the LANRAX Reference Format in the way of strings and optional strings. A string is represented as {StringName}, and it can be regarded as a string variable. Also, a string can be directly expressed by a combination of some strings, like <{String1}: {String2}, {String3}>, which means string1 + ": " + string2 + ", " + string3 where + is string concatenation. An optional string is in the format [content] or ~[content] or [content]~, and it outputs its content only when all of its neighbor strings (the front one and back one) without ~ on its side are not null. That means, for [], it demands both the front one and back one to be not null for content output. For ~[], it demands the back one to be not null to output, and the front one should be not null for []~. A string with zero length is null.

For example:

{NAME1} = "YEE", {NAME2} = "172", {NAME3} = null, {NAME4} = "is here"

{NAME1}[-]{NAME2} = "YEE-172"

{NAME1}[-]{NAME3} = "YEE"

{NAME1}[-]~{NAME3} = "YEE-"

{NAME3}[-]~{NAME2} = "172"

<Mr. {NAME1}[-]{NAME2}>[ ]{NAME4} = "Mr. YEE-172 is here"

<{NAME3}[-]{NAME3}>[ ]{NAME4} = "is here"

{NAME1}[-]{NAME3}[+]{NAME4} = "YEEis here" // Please notice that only the nearest neighbor one string could affect the output of [].

For LANRAX, the final output should be {LANRAX} , which equals to<@ {AUTHOR}; {PUBLISHER}; {TITLE}; {CITATION}; {TIME}.>.

Please read the following rules really really carefully! Any different character (including a space) between your answer and the true answer will cause a wrong answer.

#### AUTHOR

•           There can be multiple authors. The author names are {Author1}, {Author2}, ....., {Author[x]}, [x] is the number of the authors.

–          The name of author should be presented in this format {Initials}[ ]{Author[x]FamilyName}. The {Initials} is the combination of first letters of the words in the {Author[x]FirstName} with a dot behind, and they are separated by a space. For example, if the family name is Black and the first name is Vince, the result should be V. Black. If the first name is William Jafferson and the family name is Clinton, the result should be W. J. Clinton.

•           If there is no author, {AUTHOR} is null.

•           If there is one author, {AUTHOR} should be {Author1}.

•           If there are two authors, {AUTHOR} should be {Author1} and {Author2}

•           If there are three to five authors, {AUTHOR} should be like {Author1}, {Author2}, {Author3} and {Author4} (Similar format for 3 and 5 authors).

•           If there are more than five authors, {AUTHOR} should be {Author1} et al.

•           If there is any word in {Author[x]FamilyName} and Author[x]FirstName starting from lower letter, convert it to upper letter.

#### PUBLISHER

•           The {PUBLISHER} should be <<{City}[, ]{Province}>[, ]{Country}>[: ]{Publisher}.

•           For example:

{City} = "Shenzhen", {Province} = "Guangdong", {Country} = "China", {Publisher} = "SUSTech"

{PUBLISHER} = "Shenzhen, Guangdong, China: SUSTech"

Another example:

{City} = null, {Province} = null, {Country} = null, {Publisher} = "Moon Station"

{PUBLISHER} = "Moon Station"

#### TITLE

•           The {TITLE} should be ~["]{Title}["]~.

#### CITATION

•           If {Type} = "BOOK", {CITATION} should be

<~[From ]{BookName}[~[, ]{Pages}]~>[~[ written by ]{BookAuthor}]~.

The string {Pages} = <~[page ]{PageNumbers}>, and {PageNumbers}derives from an array of integers in {PageNumberArray} which are the page numbers included. If there is only one page in {PageNumberArray}, then {PageNumbers} is equal to that page number. If there are multiple page numbers in {PageNumberArray}, {PageNumbers} should be all page numbers in increasing order separated by a semicolon and a space, and the last one should be separated by and (similar with authors). The continuous pages (more than 1 page) should be combined into a range, which is in the format of start-end.

–          Example 1:

•           Page numbers are [1,2,4,5,6,9,8,10,15].

•           {Pages} = "page 1-2, 4-6, 8-10 and 15".

–          Example 2:

•           Page number is [4, 6]

•           {Pages} = "page 4 and 6" .

–          Example 3:

•           Page number is [1,2,3]

•           {Pages} = "page 1-3".

•           If {Type} = "CONFERENCE", {CITATION} should be <~[In ]{ConferenceName}>[~[ held in ]{ConferencePlace}]~.

•           If {Type} = "ONLINE", {CITATION} should be

•           Please notice that {BookAuthor} is not represented in the rule of {Author}, but just as the raw input text.

#### TIME

•           {TIME} = <~[{Date}[ ]~]{MonthAbbr}>[ ]{Year}, where the {MonthAbbr} is converted from {Month} through the following table.

 {Month} {MonthAbbr} 1 Jan. 2 Feb. 3 Mar. 4 Apr. 5 May 6 Jun. 7 Jul. 8 Aug. 9 Sep. 10 Oct. 11 Nov. 12 Dec.

## Input

The input format is as following:

The first line is an integer n

On each following line, the input format is "String name":"String content". All possible String name and corresponding content formats are listed as follows.

•           "Author[x]FirstName":string containing one or multiple words in alphabet separated by a space, length<20

•           "Author[x]FamilyName":string containing one or multiple words in alphabet separated by a space, length<20

•           "City":string containing one or multiple words in alphabet, length<20

•           "Province":string containing one or multiple words in alphabet, length<20

•           "Country":string containing one or multiple words in alphabet, length<20

•           "Publisher":string containing one or multiple words in alphabet, length<20

•           "Title":string containing one or multiple words in alphabet, digital number length<60

•           "Type":enum can only be "BOOK", "CONFERENCE" or "ONLINE"

•           "BookName": string containing one or multiple words in alphabet and digital number, length<60

•           "BookAuthor": string containing one or multiple words in alphabet and digital number, length<20

•           "PageNumberArray":array(integer) all elements are positive integers no more than 100000000 and separated by a semicolon, array length in [1, 200], no duplicated element.

•           "ConferenceName":string containing one or multiple words in alphabet and digital number, length<60

•           "ConferencePlace":string containing one or multiple words in alphabet

•           "WebsiteName":string containing one or multiple words in alphabet and digital number, length<60

•           "WebHttpLink":string string length<200

•           "Date":integer in range [1,31]

•           "Month":integer in range [1,12]

•           "Year":integer in range [1, 2050]

We guarantee that if there are m(m<=20) authors, each author[x] with x  in [1,m] will appear at least once in the input. No duplicated string name will appear in the input. No special characters such as quote mark will appear in the content.

Please notice that the input order of the strings is not guaranteed, and the strings that do not appear in the input are regarded as null.

## Output

The output is the string {LANRAX}:

{LANRAX} = <@ {AUTHOR}; {PUBLISHER}; {TITLE}; {CITATION}; {TIME}.>

No line break at the end of the output.

## Sample Input

13
"Author1FirstName":"vince"
"Author1FamilyName":"black"
"Author2FamilyName":"Lanran"
"City":"Shenzhen"
"Province":"Guangdong"
"Publisher":"VCN Center"
"Title":"How to set fire when you become a ghost"
"Type":"ONLINE"
"WebsiteName":"Lanran Club"
"Date":"9"
"Month":"11"
"Year":"2019"


## Sample Output

@ V. Black and Lanran; Shenzhen, Guangdong: VCN Center; "How to set fire when you become a ghost"; Accessed online from Lanran Club, link:http://lanran.club/; 9 Nov. 2019.

[Submit][Status]