May 2023 C/C++ (Level 7) real question analysis #中国 Electronics Society # National Youth Software Programming Level Examination

Insert image description here

C/C++ Programming (Levels 1~8) All real questions・Click here

Problem 1: The Castle Problem

1 2 3 4 5 6 7
############################
1 # | # | # | | #
##### —#####—#—#####—#
2 # # | # # # # #
#—#####—#####—#####—#
3 # | | # # # # #
#—#########—#####—#—#
4 # # | | | | # #
############## ##############
(Picture 1)
# = Wall
| = No wall
- = No wall
Figure 1 is a topographic map of a castle. Please write a program to calculate how many rooms there are in the castle and how big the largest room is. The castle is divided into m×n (m≤50, n≤50) squares, and each square can have 0~4 walls.
Time limit: 1000
Memory limit: 65536
input
The program reads data from the standard input device. Lines 1 and 2 each contain an integer, which are the number of blocks in the north-south and east-west directions respectively. In the following input lines, each square is described by a number (0≤p≤50). Use a number to represent the walls around the block, 1 for the west wall, 2 for the north wall, 4 for the east wall, and 8 for the south wall. Each block represents its surrounding wall

Guess you like

Origin blog.csdn.net/gozhuyinglong/article/details/132656218