Seven-Character Couplets (APCS 2021-09 Beginner)

Points 100 1.0s 256M

In 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.

Problem page help

Keyboard shortcuts

Main features

  • Sample tests — Runs the sample cases bundled with the problem and auto-compares against the expected output.
  • Custom test — Run your code with your own stdin. Optionally tick the "Compare with expected (diff)" box to verify against expected output line-by-line.
  • Template — Paste the default code template you set on your profile page.
  • Collab — Edit this problem together with classmates in real time.
  • Auto-draft — Editor contents auto-save to your browser every 1.5 seconds (per account / problem / language).
  • Submit — Send your code to the judge for grading; returns AC / WA / TLE etc.

Limits

  • Source code: at most 65,536 characters
  • Custom test stdin and expected output: at most 1 MB each (≈1 million characters)
  • Custom test and sample test share the sandbox; about 1 request per 3 s per user (sample test: 1 per 1 s)
  • Custom test and sample test both have a 15 second wall-clock cap (the official judge still uses the problem time limit)
  • Interactive problems do not offer custom test (cannot simulate interaction with the judge).
  • Submitting has no rate limit, but rapid repeated submissions on the same problem are treated as score farming.