3095 - I2P(I)2024_Hu_Hw6 Scoreboard

Time

2024/10/14 20:30:00 2024/10/28 18:30:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
14025 Let the Queen cooks
14466 Counting herds

14025 - Let the Queen cooks   

Description

I loved the part when she said “It’s cooking time!” And cooks everywhere, it really shows that she really cooks all the time.

Pin on Bakery logo design

Given a n x n board, each tile is either 1 or 0, you need to put n queens and count how many solutions are legal as the rules:

  • 0 means you can put the queen in that tile.
  • 1 means the tile is occupied, and we can't put the queen there.
  •  Queens can't attack each other, therefore each row, column, and diagonal has only 1 queen.

For example, the answer of the sample input is 1 as the picture below speaks for itself. There is no other possible move.

Little help from the queen: use scanf("%1d") to scan 1 digit number.

Input

First line is an integer n (1 <= n <= 10)

The next n lines is the board state, each n digit, consist only number 1 and 0.

It's guaranteed that every row has atleast 1 number 0

Output

Output an integer with how many solution the input has.

Following with '\n'

Sample Input  Download

Sample Output  Download

Tags




Discuss




14466 - Counting herds   

Description

Elephants are social animals, and for them, adjacent elephants are considered part of the same herd (diagonal adjacency does not count). In other words, if an elephant is located at coordinates (x, y), then the elephants at (x+1, y)(x-1, y)(x, y+1), and (x, y-1) belong to the same herd.

Given a map of size n*m, where # represents an elephant and . represents an empty space, the task is to determine the total number of herds.

 

Sample:

.#.#.
####.
##..#
....#
##.##

Input

The first line contains two integers, n and m.

1 ≤ n, m ≤ 1000

The following n lines each contain a string of length m, where each character is either # or ..

Output

Output the number of herds.

Note that you do NOT need to print '\n' at the end of the output.

Sample Input  Download

Sample Output  Download

Tags




Discuss