CF1906K.Deck-Building Game

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are playing a deck-building game with your friend. There are NN cards, numbered from 11 to NN . Card ii has the value of AiA_i .

You want to build two decks; one for you and one for your friend. A card cannot be inside both decks, and it is allowed to not use all NN cards. It is also allowed for a deck to be empty, i.e. does not contain any cards.

The power of a deck is represented as the bitwise XOR of the value of the cards in the deck. The power of an empty deck is 00 .

The game is balanced if both decks have the same power.

Determine the number of ways to build two decks such that the game is balanced. Two ways are considered different if one of the decks contains at least one different card. Since the answer can be very large, calculate the answer modulo 998244353998\,244\,353 .

输入格式

The first line consists of an integer NN ( 2N1000002 \le N \le 100\,000 ).

The following line consists of NN integers AiA_i ( 1Ai1000001 \le A_i \le 100\,000 ).

输出格式

Output an integer representing the number of ways to build two decks such that the game is balanced. Output the answer modulo 998244353998\,244\,353 .

输入输出样例

  • 输入#1

    4
    16 12 4 8

    输出#1

    9
  • 输入#2

    4
    1 2 4 8

    输出#2

    1
  • 输入#3

    2
    1 1

    输出#3

    5
  • 输入#4

    6
    1 1 1 2 2 2

    输出#4

    169

说明/提示

Explanation for the sample input/output #1

Denote SS and TT as the set of cards in your deck and your friend's deck, respectively. There are 99 ways to build the decks such that the game is balanced.

  • S={}S = \{\} and T={}T = \{\} . Both decks have the power of 00 .
  • S={2,3,4}S = \{2, 3, 4\} and T={}T = \{\} . Both decks have the power of 00 .
  • S={}S = \{\} and T={2,3,4}T = \{2, 3, 4\} . Both decks have the power of 00 .
  • S={2,4}S = \{2, 4\} and T={3}T = \{3\} . Both decks have the power of 44 .
  • S={3}S = \{3\} and T={2,4}T = \{2, 4\} . Both decks have the power of 44 .
  • S={2,3}S = \{2, 3\} and T={4}T = \{4\} . Both decks have the power of 88 .
  • S={4}S = \{4\} and T={2,3}T = \{2, 3\} . Both decks have the power of 88 .
  • S={3,4}S = \{3, 4\} and T={2}T = \{2\} . Both decks have the power of 1212 .
  • S={2}S = \{2\} and T={3,4}T = \{3, 4\} . Both decks have the power of 1212 .

Explanation for the sample input/output #2

The only way to make the game balanced is to have both decks empty.

Explanation for the sample input/output #3

There are 55 ways to build the decks such that the game is balanced.

  • S={}S = \{\} and T={}T = \{\} . Both decks have the power of 00 .
  • S={1,2}S = \{1, 2\} and T={}T = \{\} . Both decks have the power of 00 .
  • S={}S = \{\} and T={1,2}T = \{1, 2\} . Both decks have the power of 00 .
  • S={1}S = \{1\} and T={2}T = \{2\} . Both decks have the power of 11 .
  • S={2}S = \{2\} and T={1}T = \{1\} . Both decks have the power of 11 .
首页