Data Structures & AlgorithmsVery hardCodeforces Div2 D · ICPC regional

How many ways can the six numbers [1, 2, 3, 4, 5, 6] be assigned to three labelled groups (group A, group B, group C), each number going to exactly one group, so that all three groups have the same sum? Empty groups are not allowed.

  1. A. 3
  2. B. 12
  3. C. 27
  4. D. 6

Correct answer: D. 6

The three sums must each equal total/3 = 7. Count labelled assignments with a bitmask DP over which numbers are in group A and group B; halving the count assumes a symmetry that the labels break.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic