3252 - I2P(I)2025_Chou_Hu_Hw4_ClassB Scoreboard

Time

2025/10/14 20:30:00 2025/10/21 18:30:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
14764 Ceobe IQ Test
14767 Doctor's files

14764 - Ceobe IQ Test   

Description

Ceobe is a curious girl, but it is really hard to determine the IQ of this cute Perro girl, whether she is a hidden genious or just a normal glutton is up to you.

So the task Doctor gave her is to count how many ways can she put $M$ queens inside a $N \times N$ chessboard so that no two queens attack each other. In the game of chess, the queen can attack freely diagonally, horizontally and vertically.

Ofcourse Ceobe will struggle with this complex of a question, so Doctor gave her some hint:

  • Help
  • If $M=0$ and  $N=3$, only 1 board is possible:
  • If $M=1$ and $N=3$, there will be 9 possible boards:
  • If $M=2$ and $N=3$, there will be 8 possible boards:
  • If $M=3$ and $N=3$, there're no board that can satisfy.

Image credit: Arknights Official youtube channel

Input

The input will consist of 1 line containing 2 numbers:

  • The first number $M$ will be the number of queens to put in.
  • The second number $N$ is the size of the chessboard.

Constraints

  • Testcase 1-4: $M = N$
  • Testcase 5-6: $M \neq N$

Output

Count how many ways to put $M$ queens inside a $N \times N$ chessboard.

Sample Input  Download

Sample Output  Download

Tags




Discuss




14767 - Doctor's files   

Description

Doctor is currently cleaning the computer that contain's all of Rhode Island patient's data, but the files are hidden so deep no one but you can retrieve it and help Doctor organize them again.

Your task now is to traverse the file tree and retrieve them in a special order called "PreOrder". By that order means that you have to print out the name of the folder first before going in to its content.

For example:

 

Doctor need to give this list to Kal'tsit - Doctor's boss, so your code MUST abide by this code template, and the function gen MUST also be a generator function, meaning that it can only use yield statement to return value.

 

from ast import literal_eval

def gen(tree: tuple):
    """
    The tree is a tuple (data, [child1, child2, ...])
    Each child is its own tree
    The list of childs can be empty.
    """

genVar = gen(literal_eval(input()))
while True:
    try:
        print(next(genVar))
    except StopIteration:
        break

Hint: Use yield from to yield recursively.

Input

Complete the function gen with the template code.

Output

Generate the list in "Preoder" order.

Sample Input  Download

Sample Output  Download

Tags




Discuss