Logo
(追記) (追記ここまで)

29886번 - Magical BF 1 점수다국어언어 제한

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB73322843.077%

문제

John learned at school that in many East Asian languages texts can be written from left to right as well as from top to bottom. He got especially curious whether it's possible to write a text such that it can simultaneously be read both ways. John kept puzzling in programming class as well and now wants to write code such that it would solve the tasks when read by rows (top to bottom and left to right), as well as when read by columns (left to right and top to bottom). Naturally, he needed a suitable language for this and John chose a language called BF for experimenting.

The memory of a BF program is an infinite array $M$ with cells numbered from left to right ($M_0,ドル $M_1,ドル \ldots). Each cell contains a nonnegative integer that can be arbitrarily large. Additionally there is a data pointer that in the beginning of execution points to the leftmost cell ($M_0$).

The execution of a program starts from its first command and in general after the execution of each command the program moves on to the next command in the sequence. Altogether there are six commands in the language, each one denoted by one character:

Command Meaning
> Moves the data pointer to the right by one cell.
< Moves the data pointer to the left by one cell if the data pointer does not point to the leftmost cell; otherwise does nothing.
+ Increases the cell at the data pointer by one.
- Decreases the cell at the data pointer by one if the cell is currently positive; otherwise does nothing.
[ If the cell at the data pointer is zero, then jumps forward to the corresponding ']' symbol; otherwise does nothing.
] If the cell at the data pointer is nonzero, then jumps back to the corresponding '[' symbol; otherwise does nothing.

Help John write magical BF programs for solving the five tasks listed below.

As a solution to each task submit an $N \times N$ grid of BF program code (where 1ドル \le N \le 1000$). The code does not have to be the same when read by rows and by columns, but must solve the task correctly in both cases. The solution text can only contain the characters '>', '<', '+', '-', '[' and ']' and must completely fill the grid. For any allowed input, the code must not execute more than 10ドル$ million commands.

Task: The cells $M_0$ and $M_1$ of the array contain the integers $x$ and $y$ (0ドル \le y \le x \le 200$), all other cells contain zeros. Write the difference $x-y$ into the cell $M_0$.

Input example:

Output example:

In the output, it only matters that the cell $M_0$ contains the difference of $x$ and $y$ (in this case, 7ドル - 5 = 2$), other cells may contain any numbers (for example, 1500ドル,ドル 0ドル,ドル 42ドル,ドル \ldots).

입력

출력

제한

힌트

예제

Task: Add the contents of the cells $M_0$ and $M_1$ and put the result into the cell $M_0$. The rest of the cells contain the value 0ドル$ in the beginning of the execution.

Solution:

>[-<+>]
[++++<>
<----><
+++++<<
>---]><
-<><>[>
]><<<><

Reading by lines: >[-<+>][++++<><----><+++++<<>---]><-<><>[>]><<<><

Reading by columns: >[<+>-][+-+-<>-+-+-><<+-+-<<++-+]><><><>[>]><<<><

In both cases the resulting code solves the given task.

점수

A correct solution to each task is given $N$ points, where $N$ is the side length of the solution's grid. A solution that violates restrictions in the task statement always gets 0ドル$ points.

출처

Olympiad > Estonian Informatics Olympiad > 2020-21 > Open Competition 6-1번

제출할 수 있는 언어

Text

채점 및 기타 정보

  • 3점 이하를 획득해야 를 받는다.
  • 맞힌 사람의 정렬 기준은 점수의 오름차순이다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /