#P3692. Exam Card Optical Mark Recognition

    ID: 16943 Type: Default 1000ms 256MiB

Exam Card Optical Mark Recognition

Exam Card Optical Mark Recognition

A university's Software Engineering department is conducting a written exam using machine‐readable answer sheets. The exam paper consists of a header section and a section for single-choice questions. The header contains the candidate's ID in 16-bit binary and a test paper type indicator. You are required to implement the following functionalities:

  1. ID Check.

    The candidate’s ID is provided as a 16-digit unsigned binary number. Convert it to its decimal representation. The valid range is \(1 \leq id \leq 10000\). If the ID is invalid, output Wrong ID and ignore the remaining parts for this test paper (although you must still read them from input). Otherwise, output ID: followed by the decimal value.

  2. Test Paper Type Check.

    The next input is a 2-digit string (each digit either 0 or 1, with no whitespace in between) representing whether the test paper type A and B are marked respectively. The correct type is deduced from the last bit of the binary exam ID: if the last bit is 0 then it is type A; if it is 1 then it is type B. A candidate marks correctly only if exactly the correct option is marked (i.e. for type A the answer must be 10 and for type B it must be 01). Output Type Correct if the candidate marks correctly; otherwise output Type Incorrect. In any case, continue processing the test paper.

  3. Scoring for Single-Choice Questions.

    Before processing the test papers, the number of single‐choice questions \(n\) and the standard answers are provided. The standard answer for each question is given as a line of 4 digits (each 0 or 1) corresponding to options A, B, C, and D (only one of which is 1 and the others are 0). For each test paper, the candidate’s answers for the \(n\) questions are given in the same format (each as a line containing 4 digits with no spaces). A candidate’s answer for a question is correct if and only if the candidate has marked the same option as the standard answer (i.e. the correct position is marked (1) and all other positions are unmarked (0)). Compute the candidate’s score as a floating-point number rounded to one decimal place, where the total score is 100 and each question carries an equal weight.

Input Format:

  • The first line contains an integer \(n\) representing the number of single-choice questions.
  • The next \(n\) lines each contain 4 digits (0 or 1) representing the standard answer for each question.
  • The following line contains an integer \(T\) representing the number of test papers.
  • For each test paper, the following data is provided in order:
    • A line containing a 16-digit binary string representing the exam ID.
    • A line containing 2 digits (each 0 or 1, with no spaces) representing the test paper type filled.
    • \(n\) lines each containing 4 digits (0 or 1) denoting the candidate’s answer for each question.

Output Format:

  • If the exam ID is invalid, output a single line: Wrong ID.
  • If the exam ID is valid, output three lines in order:
    1. ID: followed by the decimal exam ID.
    2. Type Correct or Type Incorrect based on the test paper type check.
    3. The candidate’s score as a floating-point number rounded to 1 decimal place.

Note: Even if the exam ID is invalid, you must still read the remaining inputs for that test paper but produce no further output.

inputFormat

The input begins with an integer (n) on a single line. The next (n) lines contain the 4-digit standard answer for each single-choice question. The following line contains an integer (T), the number of test papers. For each test paper, the following input is given in order:

  1. A line with a 16-digit binary string representing the exam ID.
  2. A line with a 2-digit string representing the marked test paper type (first digit for type A, second for type B).
  3. (n) lines each containing 4 digits (each digit is 0 or 1) representing the candidate's answer for each question.

All numbers are given without spaces between digits where specified.

outputFormat

For each test paper:

  • If the exam ID is invalid (i.e. its decimal value is not within [1, 10000]), output a single line:

    Wrong ID

  • Otherwise, output three lines:

    1. ID: followed by the decimal representation of the exam ID.
    2. Type Correct if the candidate marked exactly the correct test paper type, or Type Incorrect otherwise.
    3. The candidate's score as a number rounded to 1 decimal place.

sample

2
1000
0100
3
0000000000001010
10
1000
0100
0000000000010101
10
1010
0100
0000000000000000
01
1000
0100
ID: 10

Type Correct 100.0 ID: 21 Type Incorrect 50.0 Wrong ID

</p>