Seven-Character Couplets (APCS 2021-09 Beginner)
Points 100 1.0s 256MIn Chinese, syllables are classified by pronunciation into level tone (平聲) and oblique tone (仄聲). We mark a level tone as \(0\) and an oblique tone as \(1\).
A seven-character couplet consists of two lines, each with exactly seven characters.
A seven-character couplet has three rules:
- A. Positions 2 and 4 must have different tones, and positions 2 and 6 must have the same tone (in each line).
- B. The last character of the first line must be oblique (\(1\)), and the last character of the second line must be level (\(0\)).
- C. Between the two lines, the tones at positions 2, 4, 6 must differ.
Given \(n\) couplets, each described with \(0\)/\(1\), output which rules each couplet violates; if none of the three rules is violated, output None.
Input
The first line contains a positive integer \(n\), the number of couplets. The following \(2n\) lines each contain \(7\) digits (each \(0\) or \(1\)) separated by spaces. Lines \(2i-1\) and \(2i\) are the first and second lines of the \(i\)-th couplet.
Constraints
- \(1 \le n \le 30\)
- Every digit is \(0\) or \(1\)
Output
For each couplet, output one line listing the violated rules: concatenate the violated rule letters in the order A, B, C (e.g. violating both A and C gives AC); if all three rules are satisfied, output None.
Scoring
The time limit for each test case is \(1\) second; your score is the sum over the test cases you pass.
Sample Input 1
1
1 1 0 0 0 1 1
1 0 0 0 1 1 0
Sample Output 1
AC
Sample Input 2
1
0 1 1 0 1 1 1
1 0 1 1 0 0 0
Sample Output 2
None
Sample Input 3
2
0 1 1 0 0 0 1
1 0 1 1 0 1 1
0 1 0 0 0 0 1
0 0 0 0 0 1 1
Sample Output 3
AB
ABC
Source
APCS programming exam, September 2021, Problem 1.
Log in to write and submit code.
Log in