Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 300 点
問題文
英小文字、,
、"
からなる長さ N の文字列 S が与えられます。S に含まれる "
の個数は偶数であることが保証されています。
S に含まれる "
の個数を 2K 個とすると、各 i=1,2,\ldots,K について 2i-1 番目の "
から 2i 番目の "
までの文字のことを 括られた文字 と呼びます。
あなたの仕事は、 S に含まれる ,
のうち、括られた文字 でないもの を .
で置き換えて得られる文字列を答えることです。
制約
- N は 1 以上 2\times 10^5 以下の整数
- S は英小文字、
,
、"
からなる長さ N の文字列 - S に含まれる
"
の個数は偶数
入力
入力は以下の形式で標準入力から与えられる。
N S
出力
答えを出力せよ。
入力例 1
8 "a,b"c,d
出力例 1
"a,b"c.d
S のうち "a,b"
が括られた文字であり、c,d
は括られた文字ではありません。
S に含まれる ,
のうち、括られた文字でないのは S の左から 7 番目の文字なので、7 番目の文字を .
で置き換えたものが答えとなります。
入力例 2
5 ,,,,,
出力例 2
.....
入力例 3
20 a,"t,"c,"o,"d,"e,"r,
出力例 3
a."t,"c."o,"d."e,"r.
Score : 300 points
Problem Statement
You are given a string S of length N consisting of lowercase English letters, ,
, and "
. It is guaranteed that S contains an even number of "
.
Let 2K be the number of "
in S. For each i=1,2,\ldots,K, the characters from the (2i-1)-th "
through the (2i)-th "
are said to be enclosed.
Your task is to replace each ,
in S that is not an enclosed character with .
and print the resulting string.
Constraints
- N is an integer between 1 and 2\times 10^5, inclusive.
- S is a string of length N consisting of lowercase English letters,
,
, and"
. - S contains an even number of
"
.
Input
The input is given from Standard Input in the following format:
N S
Output
Print the answer.
Sample Input 1
8 "a,b"c,d
Sample Output 1
"a,b"c.d
In S, "a,b"
are enclosed characters, and c,d
are not.
The ,
in S that is not an enclosed character is the seventh character from the left in S, so replace that character with .
to get the answer.
Sample Input 2
5 ,,,,,
Sample Output 2
.....
Sample Input 3
20 a,"t,"c,"o,"d,"e,"r,
Sample Output 3
a."t,"c."o,"d."e,"r.