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

3138번 - STUPOVI 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB69282848.276%

문제

Due to the big number of cars parked on the sidewalk and problems they cause for the pedestrians, the city government decided to separate some parts of the sidewalk from the road with little pillars.

The sidewalk is divided into parts 1 meter long. The sidewalk is represented as a string where a dot ('.') means that someone can park on that location and an 'X' represents the location of a pillar (which stops the cars from parking there).

All the cars in the town are L meters long. To park on the sidewalk, they need at least L consecutive meters without pillars.

For example, if the string '..X...X..' represents the sidewalk, and the car is 2 meters long, there are 4 different spots where the car can be parked (starting at the first, fourth, fifth and eighth meters).

As the number of available pillars is limited (there are only N available), the government wants to put the pillars so that:

  1. The number of different available parking spots is the smallest possible.
  2. If there are multiple ways to meet the first condition, choose one that requires the least number of additional pillars to be placed.

Write a program that, given the number of available pillars N, the length of the cars in meters L and the current layout of the sidewalk, finds any arrangement that satisfies both conditions.

입력

The first line of input contains two integers, N and L (1 ≤ N, L ≤ 100), the number of available pillars and the length of the cars in meters.

The second line consists of up to 100 characters that describe the current layout of the sidewalk. Each character represents a meter of the sidewalk. The capital letter 'X' represents a meter that cannot beused for parking because a pillar is already there. The character '.' represents a meter which is currently free and can currently be used for parking.

출력

Output the layout of the sidewalk after placing additional pillars (if needed), in the same format as in the input.

Note: The solution may not be unique.

제한

예제 입력 1

3 4
.........

예제 출력 1

..X...X..

예제 입력 2

2 3
X.......XX.....XX..X....X

예제 출력 2

X..X....XX..X..XX..X....X

힌트

Clarification for first sample: although we have three pillars available, we can place two so that no car can park.

Clarification for second sample: if we choose this final layout, there are four different locations for a car to park. There is no better arrangement.

출처

Olympiad > Croatian Highschool Competitions in Informatics > 2007 > National Competition #1 - Juniors 1번

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

출처

대학교 대회

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

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