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.