homework

아직 제출이 없습니다시간 제한3초메모리 제한1024 MB

문제

There are NN (2N10002 \le N \le 1000) students in line, name them s_0,s_1,,s_N1s\_0, s\_1, \cdots, s\_{N-1} by their order.

For each student, you have to check whether he/she did the homework or not, and you can ask:

  • Q1 defined as 0 standing for "Have you finished the homework?" or
  • Q2 defined as 1 standing for "Are you late for the homework?".

However, due to the weird culture in the school, if a student has to answer "no" then he/she will hesitate to answer until the class ends. (Of course, you know that this student expressed "no".)

You prepare the questions q_0,q_1,,q_N1q\_0, q\_1, \cdots, q\_{N-1} for the students and they will come to answer in order, and you have to wait for their answers.

  • i.e., if s_0,s_1,s_M1s\_0, s\_1, \cdots s\_{M-1} answer YES and s_Ms\_M expresses "no", then you will only receive MM YES's.
  • so if s_0,s_1,s_N1s\_0, s\_1, \cdots s\_{N-1} answer YES then you will receive NN YES's.

Here, for the COVID-19 situation, you write the questions on the computer and upload them online and what you receive is a big YES on the monitor. You can only get the sequence of answers.

However, the online system was broken so the questions get arranged by a pre-chosen order i_0,i_1,,i_N1i\_0, i\_1, \cdots, i\_{N-1}.

  • i.e., if you input q_0,q_1,,q_N1q\_0, q\_1, \cdots, q\_{N-1}, then the questions will be asked by the order q_i_0,q_i_1,,q_i_N1q\_{i\_0}, q\_{i\_1}, \cdots, q\_{i\_{N-1}}.

You can have at most N+Nlog_2N\lceil N + N\log\_2 N \rceil classes to ask the questions.

Write a function question:

  • input parameter: a Student object containing the information of the students' state and the order

  • \cdot.n() returns the number of students; i.e., NN

    • \cdot.ask(Q) returns the list of 'YES'’s (need not be a length of NN) based on the question list Q

      • input parameter: a list of length NN, consisting of Q1 and Q2
      • return value: ['YES' for j in range(MM)] where MM is the number of YES's: i.e., M = \max\\{m \le N \\,\vert\\, j < m \Longrightarrow s\_j \textrm{ answers } YES on \textrm{ on } Q[i_ji\_j]\\}
  • output: the list of input questions q_0,q_1,,q_N1q\_0, q\_1, \cdots, q\_{N-1} that gets NN YES's and the order i_0,i_1,,i_N1i\_0, i\_1, \cdots, i\_{N-1}

    • in the order that you need to input to computer, and the order that q_iq\_i is asked, respectively.

Assume every student either finished or was late for the homework, and the states do not change as the classes proceed.

Caution: The protected attributes in Student are named differently in the judging code.