QOJ.ac

QOJ

実行時間制限: 1.0 s メモリ制限: 256 MB 満点: 100 ハック可能 ✓

#15522. תמורה בינארית

統計

תמורה היא סדרה באורך $n$ המורכבת ממספרים שלמים מ-$1$ עד $n$, שבה כל המספרים מופיעים בדיוק פעם אחת. לדוגמה, $[1]$, $[3, 5, 2, 1, 4]$ ו-$[1, 3, 2]$ הן תמורות, בעוד ש-$[2, 3, 2]$, $[4, 3, 1]$ ו-$[0]$ אינן תמורות.

נתון לך מערך $A_1, A_2, \dots, A_N$ המורכב מ-$N$ מספרים שלמים. כל מספר שלם הוא $0$ או $1$. מצא את מספר התמורות $P$ בגודל $N$ כך שהתנאים הבאים מתקיימים:

  • $P_1 < P_2 > P_3 < P_4 \dots$
  • $A_{P_i} \equiv i \pmod 2$, לכל ($1 \le i \le N$).

מכיוון שמספר התמורות הללו עשוי להיות גדול מאוד, הדפס את התשובה מודולו $998244353$.

קלט

השורה הראשונה מכילה מספר שלם $N$ ($1 \le N \le 10^6$).

השורה השנייה מכילה $N$ מספרים שלמים מופרדים ברווחים $A_i$ — איברי המערך. מובטח כי $A_i \in \{0, 1\}$.

פלט

הדפס שורה אחת המכילה את מספר התמורות המקיימות את התנאים מודולו $998244353$.

דוגמאות

קלט לדוגמה 1

2
1 0

פלט לדוגמה 1

1

קלט לדוגמה 2

1
0

פלט לדוגמה 2

0

קלט לדוגמה 3

7
1 1 0 1 0 1 0

פלט לדוגמה 3

8

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.