#GL0000362. Chọn cá không xung đột (Bullet)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Chọn cá không xung đột (Bullet)
Bullet
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
There are distinguishable fish. Fish has integer attributes . Choose a nonempty subset of fish. Order does not matter, and distinct indices remain distinguishable even if their attributes match.
Two fish cannot both be selected if
Count all valid nonempty subsets modulo . The zero vector is allowed and has dot product zero with every vector, including another zero vector.
Input
- First line: integer .
- Next lines: integers .
Output
Print the valid subset count modulo .
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Examples
Example 1
Input
3
1 2
-1 1
2 -1
Output
5
Explanation
There are 5 valid nonempty subsets: {1}, {2}, {3}, {1,2}, {2,3}. Fish 1 and 3 are perpendicular.
Example 2
Input
10
3 2
3 2
-1 1
2 -1
-3 -9
-8 12
7 7
8 1
8 2
8 4
Output
479
Explanation
After grouping vectors by normalized directions and their perpendicular partners, multiply (2^u+2^v-1) over all groups and subtract the empty subset.