3113 - I2P(I)2024_Yang_lab6 Scoreboard

Time

2024/10/29 22:00:00 2024/10/29 22:01:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
12459 Sierpinski Carpet
14488 Big orange cat's puzzle IV

12459 - Sierpinski Carpet   

Description

This is a Sierpinski Carpet.

The construction of a Sierpinski Carpet is stated as follows. Initially, you are given a white square.

  1. Divide the square into nine subsquares in a 3-by-3 grid.

  2. Color the center subsquare with black.

  3. For the rest eight subsquare, repeat step 1

For example,

Initially (after zero iteration), there is 0 black square in the Sierpinski Carpet.

After one iteration, there is 1 black square in the Sierpinski Carpet.

After two iterations, there are 9 black squares in the Sierpinski Carpet.

After three iterations, there are 73 black squares in the Sierpinski Carpet

Given an integer k, please output number of black squares after k iterations.

Maybe Useless Hint

  • It is suggested to solve this problem using recursion. (Well ... there is mathematic solution, but hope you practice how to design recursion function)

  • Be careful with overflow. Suggest to calculate with long long int.

Input

Input contain a single integer k.

Since there will be overflow issue if k is too big, so in this problem 0 <= k < 10.

 

Output

Output the number of black squares after the k-th iteration.

Note that there is a newline character after the output.

Sample Input  Download

Sample Output  Download

Tags




Discuss




14488 - Big orange cat's puzzle IV   

Description

The only difference between this question and Big orange cat's puzzle III is the input constraints.

Based on his previous three experiences (hw4, lab4, mid1), Big Orange Cat has finally figured out which puzzle pieces to choose!

He has now completed 90% of the puzzle. The current puzzle can be represented as an n x m matrix A, with -1 indicating unfilled spaces.
Fortunately, he knows that the sum of numbers in each row should be approximately Si. However, there might be some error, so the actual sum could be in the range [Si - PSi + P].

He now has k puzzle pieces B1 to Bk. Please tell him how many ways he can use pieces from B to fill the puzzle so that each row's sum falls within the specified range. Also, find the method with the smallest lexicographical order.

The lexicographical order for this puzzle starts from the top-left corner A1,1, then A1,2, and so on. After comparing the first row, move to the second row, following a left-to-right, top-to-bottom rule. For detailed examples, please refer to the sample output.

Input

The first line of input contains four integers nmkP, separated by spaces.

The second line contains k integers B1 to Bk, separated by spaces.

The next n lines each contain m integers Ai,1 to Ai,m.

The last line contains n integers representing S1 to Sn.

Constraints

  • 1 <= nk <= 10
  • 1 <= m <= 105
  • In matrix A, the number of occurrences of -1 will not exceed 10 times.
  • -1 <= Ai, j <= 10
  • 1 <= BiSiP <= 109

Subtasks

  • testcases 1 ~ 2: n = 1, -1 will appear at most once in each row.
  • testcases 3 ~ 4: n = 1
  • testcases 5 ~ 6: n <= 10, -1 will appear at most once in each row.
  • testcases 7 ~ 8: n <= 10
  • testcases 9 ~ 10: No additional restrictions.

Output

There are two types of output based on different situations:

  1. If there is no way to fill in the puzzle: Output a single line with "baganono" (without quotes).
  2. If there is a way to fill in the puzzle:
    The first line outputs a positive integer representing the number of possible methods.
    The next n lines each output m integers representing the matrix filled using the method with the smallest lexicographical order.

Please remember to print "\n" at the end, and dont print space (" ") at the end of every line.

Sample Input  Download

Sample Output  Download

Tags




Discuss