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

31599번 - Personality Test 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 1024 MB78534872.727%

문제

There are $n$ students taking a personality test consisting of $m$ questions. The students are numbered from 1ドル$ to $n$ and the questions are numbered from 1ドル$ to $m$. For each question, each student can either answer it with a single uppercase Latin character (AZ) or not answer it. Let $S_i$ be a string of $m$ characters representing the answers of student $i,ドル where the $j$-th character of $S_i$ is an uppercase Latin character if they answered question $j,ドル or a period (.) if they did not.

Two students are considered similar if there is a set of at least $k$ questions where both students answered all questions in the set, and for each question in the set, they answered it with the same answer.

For example, let $n = 3,ドル $m = 3,ドル $k = 2,ドル $S_1 =$ BBC, $S_2 =$ ..C, and $S_3 =$ .BC. In this example, students 1ドル$ and 3ドル$ are similar since they answered questions 2ドル$ and 3ドル$ with the same answer, while students 2ドル$ and 3ドル$ are not similar since they answered only question 3ドル$ with the same answer.

You want to find a pair of integers $(a, b)$ such that $a < b$ and students $a$ and $b$ are similar, or determine if there is no such pair. If there is more than one pair, find the one with the smallest $b$. If there is still more than one pair, find the one with the largest $a$.

입력

The first line of input contains three integers $n,ドル $m,ドル and $k$ (2ドル ≤ n ≤ 5000$; 1ドル ≤ m ≤ 3000$; 1ドル ≤ k ≤ 5$). Each of the next $n$ lines contains a string of $m$ characters. The $i$-th line contains the string $S_i$.

출력

Output one line containing the integers $a$ and $b$ representing the pair of similar students as mentioned in the problem statement, or just the integer -1 if there is no such pair.

제한

예제 입력 1

3 3 2
BBC
..C
.BC

예제 출력 1

1 3

This is the example in the problem statement.

예제 입력 2

3 3 1
BBC
..C
.BC

예제 출력 2

1 2

Students 1 and 2 are similar.

예제 입력 3

3 3 3
BBC
..C
.BC

예제 출력 3

-1

There is no pair of similar students.

예제 입력 4

4 12 2
GOOD.LUCK.IN
WINNING.ICPC
ASIA.PACIFIC
CHAMPIONSHIP

예제 출력 4

2 3

힌트

출처

ICPC > Regionals > Asia Pacific > Asia Pacific Championship > The 2024 ICPC Asia Pacific Championship G번

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

출처

대학교 대회

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

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