1335 - I2P_2017_EECS_HW5 Scoreboard

Time

2017/11/15 00:00:00 2017/11/22 08:00:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
10866 Pour Water (Stones Surrounded)
11209 N queens
11672 simple exercise of pointer on array

10866 - Pour Water (Stones Surrounded)   

Description

A farmer has a crop land. The land consists of stones (S) and holes (H) as illustrated in the following figure. Note that the crop land is surrounded by the stones(S), so no need to worry about that water may flooding outside th crop land.

The farmer decides to water his crops, so he pours some water through the hole  into the land. Assume that the amount of water is infinite, and the water can move in the four directions: up, down, left, right. Please write a program to find out where the water would reach.

For example, you are given a coordinate (1,3) representing the entrance and a table representing the farmer’s land initially:

After the farmer pours water into the land, water floods throughout the holes of the land. Finally, a portion of the holes will be filled with water like the following table.

where W means the corresponding hole is filled with water.

Note that

1.      This problem involves three files.

  • function.h: Function definition of flooding.
  • function.c: Function describe of flooding.
  • main.c: A driver program to test your implementation.

You will be provided with main.c and function.h, and asked to implement function.c.

2.     For OJ submission:

       Step 1. Submit only your function.c into the submission block. (Please choose c compiler) 

       Step 2. Check the results and debug your program if necessary.

Hints:

function.h

main.c

 

Input

The first line has an integer N(1<=N<=100), which means the number of test cases.

For each case, the first line has four integers. The first and second integers R and C (3<=R, C<=500) represent the numbers of row and column of the land, respectively. The total number of elements in the land is thus R x C. The third integer Y (0<=Y<=R-1) means the row of the entrance. The forth integer X (0<=X<=C-1) means the column of the entrance. The coordinate of the entrance is thus (Y,X). The following R lines, each containing C characters, specify the elements of the farmer’s land.

Output

Print out all elements of the lands row-by-row, and there is a '\n' at the end of each line. The states of all lands should be separated by a new line character (\n).

Sample Input  Download

Sample Output  Download

Partial Judge Code

10866.c

Partial Judge Header

10866.h

Tags




Discuss




11209 - N queens   

Description

You have to place N queens on an N-by-N chessboard in a way that no two queens attack each other.

The rule is that each row, column, and diagonal of the board contains exactly one queen.

Your mission is to compute how many possible ways to place N queens on that chessboard.

Input

An integer N that represents the size of chessboard and the number of queens.

where 1<=N<=10

Output

An integer that represents the number of possible placements of  N queens.

There is no need to add '\n' at the end of output

Sample Input  Download

Sample Output  Download

Tags




Discuss




11672 - simple exercise of pointer on array   

Description

In this exercise, you should calculate the sum of a given 2 dimensional integer array.

We have written the code about reading the size and the content of the array, and we want to pass them to a function to calculate the final answer. What you need is helping us to complete the function. 

What input into the function is the pointer, the width and the length of the array, and the function has to return the sum of the whole array.

For more specific, you only need to implement the following function:

#include <stdio.h>
#include "function.h"
int get_sum(int** int_2D_array, int length, int width)
{
    // Write your code here
}

The .c and .h file below might be helpful if you wnat to know how the function and the whole program works.

For simplify the question, we garantee that the final answer can be represented as a integer.

Input

The size and the content of a 2-D array.

 

Output

The sum of the total array.

Sample Input  Download

Sample Output  Download

Partial Judge Code

11672.c

Partial Judge Header

11672.h

Tags




Discuss