#BS0000452. Trò chơi trên bảng số (Grid Game)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Trò chơi trên bảng số (Grid Game)
Grid Game
Source: Kattis – https://open.kattis.com/problems/gridgame
Version: Phuoc Hung OJ Extended
Problem Statement
Given an integer grid , select exactly cells so that no two selected cells share a row or a column. Thus every row and column is used exactly once.
The score of a selection is the smallest selected entry. Maximize this score.
Input
The first line contains . The next lines each contain integers, describing .
Output
Print the maximum possible score as a single integer.
Subtasks
Common conditions apply to all subtasks. Scoring groups are added by Phuoc Hung OJ.
.
All input values are integers.
Subtask 1 (20 points)
- .
Subtask 2 (30 points)
- .
Subtask 3 (50 points)
- .
Examples
Example 1
Input
3
3 1 4
1 5 1
2 9 1
Output
2
Explanation
Choose entries in columns . A threshold of forces both rows 2 and 3 to choose column 2, so it is impossible.
Example 2
Input
5
17 24 1 8 15
23 5 7 14 16
4 6 13 20 22
10 12 19 21 3
11 18 25 2 9
Output
21
Explanation
Choose entries in columns . Row 4 has no entry above , proving optimality.