No.1026 OGAWA's New Keyboard
レベル :
/ AI推定難易度 : 167
/ 実行時間制限 : 1ケース 1.000秒 / メモリ制限
: 512 MB / 標準ジャッジ問題
タグ : / 解いたユーザー数 199
作問者 :
Taku Hirosawa
タグ : / 解いたユーザー数 199
作問者 :
問題文最終更新日: 2020-04-17 21:16:47
English (AI translation)
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence.
Back to the original
Problem Statement
OGAWA has made a new keyboard.
This keyboard has a HEAD key. While the HEAD key is held down, the caret moves to the beginning of the line. When the HEAD key is released, the caret returns to the end of the line.
Find the string produced after OGAWA has typed $N$ times.
On the $i$-th type ($1$ ≦ $i$ ≦ $N$), the character $S_i$ is entered. Furthermore,
- when $T_i$ = $0$, it is entered with the HEAD key released ($S_i$ is added to the end of the line)
- when $T_i$ = $1$, it is entered while holding down the HEAD key ($S_i$ is added to the beginning of the line)
Input
$N$ $T_1$ $S_1$ $T_2$ $S_2$ ... $T_N$ $S_N$
$1$ ≦ $N$ ≦ $2$ x $10^5$
$T_i$ = $0$ or $1$
$S_i$ is a single lowercase letter among the 26 half-width English letters
Output
Output the final string produced.
Sample
Sample 1
Input
6 0 e 0 l 0 f 1 h 1 s 0 y
Output
shelfy
The string is entered as follows.
type1 : e
type2 : el
type3 : elf
type4 : helf
type5 : shelf
type6 : shelfy
Sample 2
Input
5 0 p 0 o 0 c 0 h 0 a
Output
pocha
Sample 3
Input
8 1 a 1 w 1 a 1 s 1 o 1 r 1 i 1 h
Output
hirosawa
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。