#JP27. 廿四金普
廿四金普
Problem Description
The school emblem of 24JP can be represented by an binary matrix.
Initially, 24JP has only a grassland.
24JP will undergo consecutive expansions.
Each expansion is described as follows:
- Copy the current 24JP times, making the length and width of 24JP times larger.
- Map each position of the matrix representing the school emblem to the copied plots.
- Cover all positions in the regions corresponding to in the matrix with buildings.
Please calculate the number of maximal connected grassland blocks in 24JP after the expansions.
A maximal connected grassland block: a collection of grasslands where any two grasslands can be reached by moving up, down, left, or right without passing outside the campus, and adding any grassland outside the collection would break this property.
You can refer to the sample for a better understanding of the problem.
Calculate the number of maximum connected grassland blocks in dl24jp after the expansions.
Maximum connected grassland block: A set of grasslands where any two pieces of grassland in the set can be reached through up, down, left, or right movements without leaving the campus. Adding any grassland outside this set will destroy the property.
Refer to the examples for better understanding.
Input Format
Read data from exp.in
.
The first line contains three integers , , and , where and are as described in the problem, and is the subtask ID.
The next lines each contain integers, describing the matrix.
Output Format
Output the answer to exp.out
.
Output a single integer representing the number of maximal connected grassland blocks.
Samples
2 2 2
0 1
0 1
1
1
Sample Explanation
Use to represent grassland and to represent buildings.
Before expansion:
1
First expansion:
- Copy times:
1 1
1 1
- Cover all positions corresponding to in the matrix with buildings:
0 1
0 1
Second expansion:
- Copy times:
0 1 0 1
0 1 0 1
0 1 0 1
0 1 0 1
- Cover all positions corresponding to in the matrix with buildings:
0 0 0 1
0 0 0 1
0 0 0 1
0 0 0 1
After expansion, it is clear that there is only one maximal connected grassland block on the right side of the campus.
3 3 6
1 0 0
1 1 1
0 0 1
13
13
Sample Explanation
The campus after each expansion is as follows:
1 0 0
1 1 1
0 0 1
1 0 0 0 0 0 0 0 0
1 1 1 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0
1 0 0 1 0 0 1 0 0
1 1 1 1 1 1 1 1 1
0 0 1 0 0 1 0 0 1
0 0 0 0 0 0 1 0 0
0 0 0 0 0 0 1 1 1
0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0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 1 1 1 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
7 4 6
1 0 0 1 1 1 0
0 1 0 0 1 0 1
1 1 1 0 1 1 0
0 1 1 1 1 1 1
0 0 1 0 0 1 1
0 1 1 0 1 0 0
1 1 1 1 0 1 1
81143
Subtasks and Constraints
For all data, it is guaranteed that , .
Subtasks are used in this task.
Subtask ID | Special Properties | Score | ||
---|---|---|---|---|
1 | N/A | 10 | ||
2 | 30 | |||
3 | 10 | |||
4 | The matrix contains no | |||
5 | The matrix contains no | |||
6 | N/A | 30 |
统计
相关
在下列比赛中: