Pizza Restaurant

시간 제한1초메모리 제한2048 MB

요약
서로 다른 두 문자열과 반복 횟수 k를 골라 첫 문자열 뒤에 두 번째 문자열을 k번 붙인 결과가 길이 제한 안에서 회문이 되게 하라.
난이도

어려움10점 중 8점

유형
문자열, 해시맵, 문자열 매칭, 수학
정답자
아직 제출이 없습니다

문제

You are given nn strings s_1,s_2,…,s_ns\_1, s\_2, \ldots, s\_n. Find any two different indices xx and yy and a positive integer kk such that the string s_xs_ys_y…s_y⏟_k timess\_{x}\underbrace{s\_{y} s\_{y} \ldots s\_{y}}\_{k\text{ times}} is a palindrome with length at most 6⋅1066 \cdot 10^6, or report that it is impossible.

입력

The first line contains a single integer nn (2≤n≤1052 \le n \le 10^5).

The next nn lines contain nn strings s_1,s_2,…,s_ns\_1, s\_2, \ldots, s\_n, one per line (1≤∣s_i∣<1061 \leq |s\_i| < 10^6). The strings consist of lowercase English letters. The total length of all strings does not exceed 10610^6.

출력

If there is no answer, output "No" (without quotes).

Otherwise, on the first line, print "Yes" (without quotes). On the second line, print three integers xx, yy, and kk (1≤x,y≤n1 \le x,y \le n, x≠yx \ne y, k≥1k \ge 1, ∣s_x∣+k⋅∣s_y∣≤6⋅106|s\_x| + k \cdot |s\_y| \le 6 \cdot 10^6). If there are multiple solutions, print any one of them.

예제3

  1. 예제 1

    입력
    2
    aa
    aa
    
    예상 출력
    Yes
    1 2 1
    
  2. 예제 2

    입력
    4
    a
    bb
    bcb
    cdc
    
    예상 출력
    No
    
  3. 예제 3

    입력
    2
    ap
    papajoj
    
    예상 출력
    Yes
    2 1 2