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

33065번 - Observing Objects 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 (추가 시간 없음) 1024 MB (추가 메모리 없음)41320711355.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.

제한

서브태스크 1 (40점)

Modified constraints apply: 1ドル \le N \le 1,000円;$ $\boldsymbol{\underline{M=1,}}$ i.e. the screen is one-dimensional.

서브태스크 2 (40점)

Modified constraints apply: 1ドル \le N,M \le 30$.

서브태스크 3 (20점)

Original constraints apply: 1ドル \le N,M \le 1,000円$.

예제 입력 1

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

예제 출력 1

3

The following image is an illustration of this test.

This test corresponds to the Subtask 2.

힌트

출처

University > 서강대학교 > CSE4152 문제해결프로그래밍실습 > 2024-2학기 기말고사 코딩 테스트 1번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

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

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