QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#21277. Неверные указания

Statistics

Farmer John купил роскошный новый программируемый трактор. Для движения он вводит строку длины $N$, $1 \le N \le 100,000$, только из F, $L$ и $R$. F двигает вперёд на единицу, $L$ и $R$ поворачивают налево и направо на $90^\circ$. Трактор начинает в $(0,0)$ лицом на север.

Введя задуманную строку, FJ вспомнил, что ошибся ровно в одном символе, но не помнит в каком! Например, вместо $R$ мог ввести F или $L$. Посчитайте различные конечные положения на плоскости (конечное направление не важно).

Входные данные

  • Строка 1: задуманная строка команд Farmer John.

Выходные данные

  • Строка 1: число конечных положений при одной опечатке.

Примеры

Входные данные 1

FF

Выходные данные 1

3

Примечание

Farmer John хочет дважды двигаться вперёд, в идеале до $(0,2)$.

Возможны четыре ошибочные строки: FL, FR, LF, RF. Они приводят соответственно в $(0,1)$, $(0,1)$, $(-1,0)$, $(1,0)$, всего три различных положения.

Автор задачи: Brian Dean, 2012

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.