Logo
(追記) (追記ここまで)

19725번 - Checking Answers to Test 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB106474042.553%

문제

Today students had a test. The test consists of $n$ multiple-choice questions. Each question has four answer options "A", "B", "C" and "D", but only one of them is correct.

The teacher knows that the students often cheat. So he wants to find all pairs of students who have similar answers. Two students have similar answers if for each of them more than half of their correct answers match with the other student's answers, and more than half of their incorrect answers match with the other student's answers.

Help the teacher find all pairs of students who have similar answers to the test.

입력

The first line of input contains one integer $n$ denoting the number of questions in the test (1ドル \le n \le 100$).

The second line contains correct answers, they are represented by a string of length $n$. The string consists of letters "A", "B", "C" and "D", the $i$-th letter is the correct answer for the $i$-th question.

The third line contains one integer $m$ denoting the number of students, who had the test today (1ドル \le m \le 100$).

Next $m$ lines contain students' answers in the same format as the correct answers. The $i$-th line contains the answers given by the $i$-th student.

출력

The first line of output must contain the number of pairs of students who have similar answers. The following lines must contain all such pairs of students, in any order. You can output the numbers in one pair in any order.

제한

예제 입력 1

3
AAA
4
ABA
ABA
CBA
CAA

예제 출력 1

1
1 2

예제 입력 2

6
ABCDAB
3
ABCCCC
BBCDCC
ACCDCC

예제 출력 2

3
1 2
1 3
2 3

힌트

출처

Olympiad > Russian Olympiad in Informatics > Russia High School Programming Contest > Russia High School Programming Contest 2019 H번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /