| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 (추가 시간 없음) | 1024 MB (추가 메모리 없음) | 413 | 207 | 113 | 55.392% |
In image processing fundamentals, determining the region where an object is located is crucial.
You are given a screen of size $N\times M,ドル consisting of $NM$ pixels. Each pixel at position $(i,j)$ has a specific RGB value represented by three integers: $R_{ij}$ (Red), $G_{ij}$ (Green), and $B_{ij}$ (Blue). Each color component is an integer in the $[0,255]$ range.
The task is to identify the number of distinct objects on the screen. Two pixels are considered part of the same object if their RGB values are identical and connected in one of the 8ドル$ possible directions: up, down, left, right, and the 4ドル$ diagonals.
An object is defined as a group of connected pixels that meet the above criteria. Write a program to determine the number of distinct objects on the screen.
The first line contains two space-separated integers, $N$ and $M,ドル denoting the size of the image. (1ドル \le N,M \le 1,000円$)
The following $N$ lines contain 3ドルNM$ integers, where each line has 3ドルM$ space-separated integers, denoting the RGB value of each pixel. Here, the 3ドルj$-th, the $(3j+1)$-th, and the $(3j+2)$-th integer of the $i$-th row denotes $R_{ij}$, $G_{ij}$, and $B_{ij}$, respectively. (0ドル \le R_{ij},G_{ij},B_{ij} \le 255$)
Output the total number of distinct objects in the screen.
Modified constraints apply: 1ドル \le N \le 1,000円;$ $\boldsymbol{\underline{M=1,}}$ i.e. the screen is one-dimensional.
Modified constraints apply: 1ドル \le N,M \le 30$.
Original constraints apply: 1ドル \le N,M \le 1,000円$.
3 3 255 0 0 255 0 0 255 0 0 255 0 0 0 255 255 0 255 0 255 0 0 255 0 0 255 0 0
3
The following image is an illustration of this test.
This test corresponds to the Subtask 2.
University > 서강대학교 > CSE4152 문제해결프로그래밍실습 > 2024-2학기 기말고사 코딩 테스트 1번