TopCoder

User's AC Ratio

NaN% (0/0)

Submission's AC Ratio

NaN% (0/0)

Tags

Description

調皮的小精靈 $chibubu$ ,為了捉弄聖誕老人 $santa$ ,決定將信件內容用各種不同效果的魔法糖果們取代,讓幼齒的 $santa$ 出糗。

$santa$ 知道魔法糖果有以下效果:
1. 雪花 * 會融化,令左右的文字消失。
2. 薯片 ~ 會把自己變成與前一個文字相同。
3. 拐杖糖 ? 會把他左右的文字互換。
4. 貪吃的小老鼠 @ 會把在它之後的所有魔法糖果通通吃掉,被吃掉的糖果不會發揮功能。
5. 所有魔法都為從頭開始依序發揮效果,發揮後就會消失。
6. 所有魔法必不相鄰,且輸入時不會出現在開頭和結尾。

Input Format

第一行輸入一個正整數 $N$,代表信件的總數。

接下來 $N$ 行,每行輸入一個長度為 $M$ 的字串,代表信件內容。所有輸入由英文、底線 _ 和魔法糖果組成。
* $1 \leq N \leq 1000$
* $1 \leq M \leq 100$

Output Format

輸出經過解密的信件內容。

若解密後為空字串,則輸出 #null

每行輸出都要換行。

Sample Input 1

2
I_loo*vve_you_Sn?ata_Claus
I_wann*tt_mr?oe_cn?adies_and_co~k@i~es

Sample Output 1

I_love_you_Santa_Claus
I_want_more_candies_and_cookies

Sample Input 2

3
h*i
he*lo~wor?d_
i_?wan~t_?one@y_*back

Sample Output 2

#null
hoowodr_
iw_annto_ney_back

Hints

Problem Source

NEOJ Problem 2969

Subtasks

No. Testdata Range Constraints Score
1 0 5
2 1 5
3 2 5
4 3 5
5 4 5
6 5 5
7 6 5
8 7 5
9 8 5
10 9 5
11 10 5
12 11 5
13 12 5
14 13 5
15 14 5
16 15 5
17 16 5
18 17 5
19 18 5
20 19 5

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 1000 65536 65536 1
1 1000 65536 65536 2
2 1000 65536 65536 3
3 1000 65536 65536 4
4 1000 65536 65536 5
5 1000 65536 65536 6
6 1000 65536 65536 7
7 1000 65536 65536 8
8 1000 65536 65536 9
9 1000 65536 65536 10
10 1000 65536 65536 11
11 1000 65536 65536 12
12 1000 65536 65536 13
13 1000 65536 65536 14
14 1000 65536 65536 15
15 1000 65536 65536 16
16 1000 65536 65536 17
17 1000 65536 65536 18
18 1000 65536 65536 19
19 1000 65536 65536 20