102822: [AtCoder]ABC282 C - String Delimiter

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:3 Solved:0

Description

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.

Input

题意翻译

# 题意简述 给定长为 $N$ 的包含小写英文字母、`,` 和 `"`(双引号)的字符串 $S$。保证 $S$ 有偶数个 `"` 字符。令 $2K$ 表示 $S$ 中 `"` 的数量,第 $2i - 1$ 个双引号和第 $2i$ 个双引号中的字符被称为是被包围的。请你将 $S$ 中没有被包围的 `,` 替换成 `.`,并输出。

Output

分数:$300$分

问题描述

你被给定一个长度为$N$的字符串$S$,它由小写字母、逗号和双引号组成。保证$S$包含偶数个双引号。

令$2K$为$S$中的双引号数量。对于每个$i=1,2,\ldots,K$,从第$(2i-1)$个双引号到第$(2i)$个双引号之间的字符被认为是< strong>被包围的。

你的任务是将$S$中每个< strong>不是被包围字符的逗号替换为点,并打印结果字符串。

约束

  • $N$是一个介于$1$和$2\times 10^5$之间的整数,包括$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$从左边数起的第七个字符,所以将该字符替换为.即可得到答案。


样例输入 2

5
,,,,,

样例输出 2

.....

加入题单

算法标签: