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

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

Tourism

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

요약
0과 1로 이루어진 문자열에서 길이가 같고 1의 개수도 같은 서로 다른 두 부분 문자열을 고를 때, 그 길이의 최댓값을 구하는 문제다.
난이도

보통10점 중 7점

유형
문자열, 누적 합, 해시맵, 투 포인터
정답자
아직 제출이 없습니다

문제

In Lineland the Ministry of Tourism has decided to prepare a sightseeing route for tourists. There are nn cities in Lineland, they are located at a straight road. The cities are enumerated from 11 to nn along this road. Some of these cities contain sights interesting for tourists. Let us introduce the value a_ia\_i, if the ii-th city has a sight then a_i=1a\_i = 1, otherwise a_i=0a\_i = 0.  

The sightseeing route for tourists will be chosen by the Ministry of Tourism. You have to provide them with two similar routes to choose from. Each route must visit a continuous segment of cities along the line: l,l+1,…,rl, l+1, \ldots, r. Two routes are similar if they visit the same number of cities, and also they visit the same number of cities that have sights.

Your task is two find two similar routes that have the maximum number of visited cities.

입력

Input contains a string that consists of characters "0" and "1". The ii-th character of the string represents a_ia\_i. The length of this string is from 33 to 10610^6. Input contains no spaces.

출력

Output four integers: s_1s\_1, t_1t\_1, s_2s\_2 and t_2t\_2 --- the numbers of the first and the last cities of the first route, and the numbers of the first and the last cities of the second route, respectively. It is guaranteed that the answer always exists.

예제1

  1. 예제 1

    입력
    10101
    
    예상 출력
    1 4 2 5