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

34427번 - paintbucket 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 2048 MB19151381.250%

문제

After pulling a wrong lever in the lab, you find yourself traveling through time and space. At some point while traveling, you passed out and have now awoken in an office. Around you are plenty of old computers. The person in charge comes over and helps you out. They tell you it's the year 1985 and that you're in the office for some computing company. They're creating a painting program for a new operating system and are struggling to create the latest feature. The person in charge gives you some more information:

"We need your help to create a computer program that implements what we will call the paint bucket. Given an image filled with colors and the location of a click, you need to output a list of coordinates that will be colored by the paint bucket."

"Here is an example. If the user were to click on the upper left red pixel with the paint bucket in Figure 1 (e.g., the user is requesting the red pixels be changed to green), then all of the green pixels in Figure 2 are the ones that would get colored."

Figure 1: The image before the user clicked on the upper left red pixel.

Figure 2: The image after the user clicked, to change several red pixels to green pixels.

"Here is a more formal description. If the user clicks on a pixel with color $c,ドル the paint bucket should color every pixel in the same 'group' as the pixel they clicked on. Any two pixels are in the same group if you can draw a path that walks across adjacent pixels while only stepping on pixels of color $c$. You can NOT take diagonal steps. Thus, in our example in the figures, note how all of the red pixels that became green are in the same group. Likewise, all of the blue pixels are in another group and each red pixel that did not change is in a group of its own."

Since you haven't made any plans for today, you decide to stick around and help out this company.

입력

The first line contains four integers, separated by spaces: the width of the image, the height of the image, the $x$ coordinate clicked by the user, and the $y$ coordinate clicked by the user. The point $(0, 0)$ is at the top left of the image and the point $(w-1, h-1)$ is at the bottom right of the image. Following this first line, you will then have $h$ lines of input and each of these lines will have $w$ integers (space separated). Each of those integers corresponds to the color $c$ of the pixel at that coordinate.

The width, $w,ドル will be in the range 1ドル \leq w \leq 1000$.

The height, $h,ドル will be in the range 1ドル \leq h \leq 1000$.

The x coordinate, $x,ドル will be in the range 0ドル \leq x \leq w-1$.

The y coordinate, $y,ドル will be in the range 0ドル \leq y \leq h-1$.

The color $c,ドル will be in the range 0ドル \leq c \leq 100$.

출력

You should output one line for each coordinate that changes color due to the click. The two components of the coordinate should be separated by a space. The coordinates should also be ordered in the following way: sort first by the $y$ value and then by the $x$ value.

제한

예제 입력 1

5 5 0 0
0 0 0 0 1
0 0 0 1 0
0 0 1 0 0
0 1 0 0 0
1 0 0 0 0

예제 출력 1

0 0
1 0
2 0
3 0
0 1
1 1
2 1
0 2
1 2
0 3

예제 입력 2

5 5 3 2
7 7 7 7 7
7 7 7 1 7
7 7 1 1 1
7 7 7 1 7
7 7 7 7 7

예제 출력 2

3 1
2 2
3 2
4 2
3 3

노트

출처

School > CS@Mines > CS@Mines HSPC 2020 D번

  • 문제를 만든 사람: Jack Garner
(追記) (追記ここまで)

출처

대학교 대회

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

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