問題一覧 > ネタ問題

No.8126 Brainfxxk easy

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 1024 MB / 標準ジャッジ問題
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 70
作問者 : UT0911 / テスター : Cafe1942
お気に入りにしたユーザー ProblemId : 13220 / 自分の提出
問題文最終更新日: 2026-03-31 23:06:21
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
yukicoder April Fool Contest 2026 (順位表) の他の問題:

Problem Statement

Brainfxxk (xx=uc) is $1$ of the esoteric programming languages. This language consists of $8$ kinds of instructions: +, -, >, <, ., ,, [, ].

Yu-ti has decided to reproduce, out of the $8$ kinds of instructions, the $4$ kinds of instructions +, -, >, <.
The behavior of each instruction is as follows.

  • + : Adds $1$ to the value of the data at the pointer's number (adds $1$ to the value of the data the pointer points to)
  • - : Subtracts $1$ from the value of the data at the pointer's number (subtracts $1$ from the value of the data the pointer points to)
  • > : Adds $1$ to the pointer's number (moves the pointer forward by $1$)
  • < : Subtracts $1$ from the pointer's number (moves the pointer backward by $1$)

The data and their values are defined as follows.
  • $N$ pieces of data are placed in $1$ row, and the pieces of data are numbered $1$, $2$,$ \cdots$, $N$ from the front.
  • The value of each piece of data is initially $0$.
  • The pointer's number is initially $1$.

Given the number of pieces of data and the code string, output the value of each piece of data after executing the code.
However, if the pointer takes the number of a nonexistent piece of data even $1$ time during execution, output error.

Constraints

  • $1 \leq N \leq 10 $
  • $1 \leq |S|\leq 100$
  • The string $S$ consists of +, -, >, <.

Input

$N$ 
$S$

Line $1$ contains $N$, the number of pieces of data.
Line $2$ contains $S$, the code string.

Output

If the pointer takes the number of a nonexistent piece of data even $1$ time, output error.
Otherwise, output the value of each piece of data separated by spaces on $1$ line.
Print a newline at the end.

Sample

Sample 1
Input
3
+++>--
Output
3 -2 0

The pointer adds to the data number $1$ it points to $3$ times, the pointer moves backward by $1$, and the pointer subtracts from the 2nd piece of data it points to $2$ times.

Sample 2
Input
3
<>>>>
Output
error

The pointer moves forward by $1$ and points to a nonexistent piece of data, so error is output. Even if the error at character $1$ is ignored, the pointer then moves backward by $4$ and points to a nonexistent piece of data.

Sample 3
Input
1
+-+-+-+-+-
Output
0

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。