Universal Cup Judging System

Universal Cup

Süre Sınırı: 3.0 s Bellek Sınırı: 1024 MB Toplam puan: 100 Hack'lenebilir ✓
İstatistikler

俾正整數 $N$ 同 $M$。

對於每個 $k = 1, 2, \dots, N + M - 1$,設 $\text{ans}_k$ 表示以下問題嘅答案。

對於一對長度都係 $N + M - 1$ 嘅序列 $(a, b)$(其中 $a = (a_1, a_2, \dots, a_{N+M-1})$ 且 $b = (b_1, b_2, \dots, b_{N+M-1})$),如果滿足以下所有條件,就稱佢為好嘅序列對:

  • $(a_1, b_1) = (1, N + 1)$
  • 對於 $i = 2, 3, \dots, N + M - 1$,滿足以下其中一個條件:
    • $(a_i, b_i) = (a_{i-1} + 1, b_{i-1})$
    • $(a_i, b_i) = (a_{i-1}, b_{i-1} + 1)$
  • $(a_{N+M-1}, b_{N+M-1}) = (N, N + M)$

對於一個好嘅序列對 $(a, b)$,定義一棵樹 $T(a, b)$ 如下:

  • 佢係一棵有 $N + M$ 個頂點嘅樹,頂點編號由 $1$ 到 $N + M$。
  • 對於每個 $i = 1, 2, \dots, N + M - 1$,存在一條連接頂點 $a_i$ 同頂點 $b_i$ 嘅邊。

對於一棵樹,設 $\text{dist}(i, j)$ 表示頂點 $i$ 同 $j$ 之間簡單路徑上面嘅邊數。呢棵樹嘅分數定義為滿足 $1 \le i < j \le N + M$ 且 $\text{dist}(i, j) = k$ 嘅整數對 $(i, j)$ 嘅數量。

求對於所有好嘅序列對 $(a, b)$,$T(a, b)$ 嘅分數之和對 $998244353$ 取模嘅值。

計算所有數值 $\text{ans}_1, \text{ans}_2, \dots, \text{ans}_{N+M-1}$,並輸出 $\sum_{k=1}^{N+M-1} (\text{ans}_k \oplus k)$,其中 $\oplus$ 表示按位異或(XOR)。

輸入格式

輸入按以下格式俾出:

N M
  • $1 \le N \le 5 \times 10^6$
  • $1 \le M \le 5 \times 10^6$
  • 所有輸入值都係整數。

輸出格式

輸出答案。

樣例 1

2 2
14

樣例 2

24 167
21925979855

樣例 3

4297614 4167924
4162418864110099

樣例說明

喺第一個樣例入面,$(\text{ans}_1, \text{ans}_2, \text{ans}_3) = (6, 4, 2)$。因此,要輸出嘅數值係 $(6 \oplus 1) + (4 \oplus 2) + (2 \oplus 3) = 7 + 6 + 1 = 14$。

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.