RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
COCI00446

Raspad

Unrated 레이팅 미적용
난이도
1s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

A nearby meadow consists of quadratic fields organized in \(n\) rows and \(m\) columns. The rows are denoted
with numbers from 1 to \(n\) from top to bottom, and the columns with numbers from 1 to \(m\) from left to
right. Some fields are grass fields (denoted with “1”), whereas some are underwater because of the heavy
spring rainfall (denoted with “0”). Two grass fields are connected if it is possible to get from one field to
another using a series of moves where, in each step, we move to the adjacent grass field located up, down,
left or right. A component is a set of mutually connected grass fields that is maximal in the sense that, if
\(A\) is a field in the component \(K\), then all the adjacent grass fields of \(A\) are also in the component \(K\).
For a given meadow \(P\) and indices \(a\) and \(b\) (\(1 \le a \le b \le n\)), \(P\) ^{a}
{b} ^{is} ^{a} ^{meadow} ^{consisting} ^{of} ^{rows} ^{between}
the \(a^{th}\) and the \(b^{th}\) row of the original meadow \(P\) (including both \(a^{th}\) and \(b^{th}\) row). The complexity of
meadow \(P\) ^{a}
} ^{is} ^{the} ^{number} ^{of} ^{components} ^{of} ^{the} ^{grass} ^{fields} ^{located} ^{on} ^{the} ^{meadow.} ^{Determine} ^{the} ^{sum
of the complexities of all possible meadows \(P\) ^{a}
\(b\) ^{.}

제약

Subtask 1 (9 points): \(n \le 100\), \(m \le 50\)

Subtask 2 (17 points): \(n \le 1\,000\), \(m \le 50\)

Subtask 3 (35 points): \(n \le 100\,000\), \(m \le 15\)

Subtask 4 (39 points): \(n \le 100\,000\), \(m \le 50\)

입력 형식

The first line of input contains the positive integers \(n\) and \(m\) — dimensions of the meadow. Each of the
following \(n\) lines contains a string of exactly \(m\) characters that denotes one row of the meadow. Each
character of the string is either the digit “0” or the digit “1”.

출력 형식

You must output the required sum of all complexities.

서브태스크
서브태스크점수설명

1

9점

\(n \le 100\), \(m \le 50\)

2

17점

\(n \le 1\,000\), \(m \le 50\)

3

35점

\(n \le 100\,000\), \(m \le 15\)

4

39점

\(n \le 100\,000\), \(m \le 50\)

예제 1
입력
4 4
1101
1111
1010
1011
출력
14
예제 2
입력
5 7
0100010
0111110
0101001
1111011
0100100
출력
33
예제 3
입력
4 12
011111010111
110000101001
110111101111
111101111111
출력
28
문제 정보

생성자가 기록되지 않았습니다.

출처 COCI 2016/2017 Olympiad

평가 및 의견

Raspad

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Raspad

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8