아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Differences

시간 제한2초메모리 제한1024 MB

요약
길이가 같은 A~D 문자열 N개가 주어질 때, 다른 모든 문자열과의 거리가 정확히 K인 특별한 문자열의 번호를 찾는다(없으면 -1).
난이도

보통10점 중 6점

유형
구현, 수학
정답자
아직 제출이 없습니다

문제

We have a list of NN strings S_iS\_i. All strings have length MM and consist only of characters A, B, C and D. Let us define the distance between two strings XX and YY as the number of indices jj, where the strings have different characters (X_j≠Y_jX\_j \neq Y\_j). We know that the list of strings S_iS\_i contains precisely one special string that has distance KK to all other strings. Note that there might be other pairs of strings with a distance of KK. We are experiencing problems finding this special string, so please write a program to help us out.

입력

The first line contains space-separated integers NN, MM and KK. Strings S_iS\_i are given in the following NN lines.

출력

Output the index ii of the special string. Strings are numbered from 11 to NN as given in the input.

제한

  • 2≤N,M≤1052 \leq N, M \leq 10^5
  • 1≤K≤M1 \leq K \leq M
  • NM≤2⋅107 N M \leq 2 \cdot 10^7

예제2

  1. 예제 1

    입력
    5 10 2
    DCDDDCCADA
    ACADDCCADA
    DBADDCCBDC
    DBADDCCADA
    ABADDCCADC
    
    예상 출력
    4
    
  2. 예제 2

    입력
    4 6 5
    AABAAA
    BAABBB
    ABAAAA
    ABBAAB
    
    예상 출력
    2