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

16612번 - Aligned Typesetting 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB300887728.519%

문제

For this problem, a sentence with n words is a sequence of n non-empty strings [w1, w2, . . . , wn]. Given a sentence, a valid typesetting of length L is a string of length exactly L which is formed by concatenating all the words in the sentence and inserting a positive number of spaces between each adjacent pair of words.

An aligned typesetting is a valid typesetting such that the number of spaces in between each adjacent pair of words is equal.

For example, given the sentence [harry, ron, hermione] and using _ to indicate a space:

  • the string __harry_ronhermione is not a valid typesetting;
  • the string harry_ron_____hermione is a valid typesetting of length 22 but it is not an aligned typesetting;
  • the string harry___ron___hermione is an aligned typesetting of length 22.

Darcy was given a sentence of n words and the desired length of typesetting L. Can you help him to figure out whether it is possible to construct an aligned typesetting of the desired length?

입력

The first line contains two integers n (1 ≤ n ≤ 106), which is the number of words, and L (0 ≤ L ≤ 106), which is the desired length of typesetting.

The next n lines describe the words. Each of these lines contains a single string wi, representing the ith word in the sentence. The word contains only lowercase letters and consists of at least 1 and at most 106 characters.

The total length of all the words in the sentence is guaranteed to be at most 106.

출력

Display if there is an aligned typesetting of the sentence with the given length.

제한

예제 입력 1

3 8
harry
j
p

예제 출력 1

No

예제 입력 2

1 5
harry

예제 출력 2

Yes

예제 입력 3

3 22
harry
ron
hermione

예제 출력 3

Yes

힌트

출처

ICPC > Regionals > South Pacific > South Pacific Region > 2018 ACM South Pacific Programming Contest A번

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

출처

대학교 대회

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

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