가장 긴 단어

면접 대비

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

요약
E-N-D 토큰이 나올 때까지 텍스트를 훑어 문자와 하이픈으로 이루어진 단어를 뽑아내고, 가장 긴 단어를 소문자로 출력하며 길이가 같으면 먼저 나온 단어를 고른다.
난이도

쉬움10점 중 3점

유형
문자열, 구현, 시뮬레이션
정답자
아직 제출이 없습니다

문제

단어는 알파벳 대소문자(a-z, A-Z)와 하이픈(-)으로만 이루어진다. 단어와, 단어가 아닌 문자(마침표, 숫자, 기호 등)가 섞인 글이 주어질 때, 가장 긴 단어를 찾는 프로그램을 작성하시오.

예를 들어 Apple의 길이는 5, son-in-law의 길이는 10, ACM-ICPC의 길이는 8이다.

입력

입력은 여러 줄의 문단으로 이루어지며, 전체 길이는 10,000자를 넘지 않는다. 한 단어의 길이는 100자를 넘지 않는다. 문자열 E-N-D가 나타나면 그 지점이 입력의 끝을 의미하므로 E-N-D와 그 이후의 내용은 무시한다. E-N-D 자체는 단어로 세지 않는다.

출력

가장 긴 단어를 소문자로 출력한다. 가장 긴 단어가 여러 개이면 글에서 가장 먼저 나오는 단어를 출력한다.

예제3

  1. 예제 1

    입력
      ACM International Collegiate Programming Contest (abbreviated as 
    ACM-ICPC or just ICPC) is an annual multi-tiered computer programming 
    competition among the universities of the world. The contest is 
    sponsored by IBM. Headquartered at Baylor University, with autonomous 
    regions on six continents, the ICPC is directed by Baylor Professor 
    William B. Poucher, Executive Director, and operates under the 
    auspices of the Association for Computing Machinery (ACM). 
    
      The 2012 ACM-ICPC Asia Hatyai Regional Programming Contest is 
    held during 15-16 November 2012. It is hosted by Prince of Songkla 
    University, Hatyai campus. E-N-D
    
    예상 출력
    international
    
  2. 예제 2

    입력
    cat son-in-law dog E-N-D
    
    예상 출력
    son-in-law
    
  3. 예제 3

    입력
    the quick brown fox E-N-D
    
    예상 출력
    quick