PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#PS0000225. Giá trị XOR tọa độ lớn thứ K (Find Kth Largest XOR Coordinate Value)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Giá trị XOR tọa độ lớn thứ K (Find Kth Largest XOR Coordinate Value)
Find Kth Largest XOR Coordinate Value
Source: LeetCode
Version: Phuoc Hung OJ Extended
Problem Statement
Given a nonnegative integer matrix of rows and columns indexed from 1, define the coordinate value at as the bitwise XOR of entries with , . Find the -th largest among the coordinate values, counting equal values separately.
Input
The first line contains integers , followed by lines of exactly integers.
Output
Print the -th largest XOR value.
Subtasks
- Subtask 1 (20 points): ; ; .
- Subtask 2 (30 points): ; ; ; .
- Subtask 3 (50 points): ; ; .
Example 1
Input
2 2 1
5 2
1 6
Output
7
Explanation
The four XOR values sorted descending are 7,5,4,0; rank 1 is 7.
Example 2
Input
2 2 2
5 2
1 6
Output
5
Explanation
The four XOR values sorted descending are 7,5,4,0; rank 2 is 5.
Example 3
Input
2 2 3
5 2
1 6
Output
4
Explanation
The four XOR values sorted descending are 7,5,4,0; rank 3 is 4.