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 أنه أخطأ في محرف واحد بالضبط، لكنه لا يتذكر أي محرف! مثلًا F أو $L$ بدل $R$. عد مواقع النهاية المختلفة الممكنة في المستوى (الاتجاه النهائي لا يهم).

الإدخال

  • السطر 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.