Universal Cup Judging System

Universal Cup

実行時間制限: 3.0 s メモリ制限: 1024 MB 満点: 100 ハック可能 ✓
統計

คุณได้รับจำนวนเต็ม $N, X, Y, K$ และ $M$ จงหาจำนวนสามสิ่งอันดับ $(A, B, C)$ ของลำดับจำนวนเต็มที่มีความยาว $N$ ซึ่งสอดคล้องกับเงื่อนไขต่อไปนี้ทั้งหมด มอดุโล $M$

  • สำหรับแต่ละ $i = 1, 2, \dots, N$ สามสิ่งอันดับ $(A_i, B_i, C_i)$ เป็นการเรียงสับเปลี่ยนของ $(1, 2, 3)$
  • ลำดับ $A$ มีเลข $1$ อยู่พอดี $X$ ตัว และมีเลข $2$ อยู่พอดี $Y$ ตัว
  • ผลรวมของจำนวนคู่ผกผัน (inversions) ของ $A$, $B$ และ $C$ มีค่าเท่ากับ $K$

ในที่นี้ จำนวนคู่ผกผัน ของลำดับ $a$ ถูกนิยามว่าเป็นจำนวนคู่ของจำนวนเต็ม $(i, j)$ ที่สอดคล้องกับ $1 \le i < j \le |a|$ และ $a_i > a_j$

ข้อมูลนำเข้า

ข้อมูลนำเข้าจะให้มาในรูปแบบต่อไปนี้:

N X Y K M
  • ค่าข้อมูลนำเข้าทั้งหมดเป็นจำนวนเต็ม
  • $2 \le N \le 50$.
  • $0 \le X, Y \le N$.
  • $X + Y \le N$.
  • $0 \le K \le \frac{3}{2}N(N - 1)$.
  • $10^8 \le M \le 10^9$.

ข้อมูลส่งออก

พิมพ์คำตอบ

ตัวอย่าง 1

3 1 1 4 998244353
24

ตัวอย่าง 2

4 0 0 18 123456789
0

ตัวอย่าง 3

50 10 20 1000 1000000000
805988728

หมายเหตุ

ในตัวอย่างแรก มีสามสิ่งอันดับ $(A, B, C)$ จำนวน $24$ ชุดที่สอดคล้องกับเงื่อนไข ตัวอย่างเช่น ถ้าเราเลือก $A = (1, 2, 3)$, $B = (3, 3, 2)$ และ $C = (2, 1, 1)$ แล้ว $(A, B, C)$ จะสอดคล้องกับเงื่อนไขทั้งหมด

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.