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

Pet

설명

tics
Frog Maša is in a lake represented by a matrix with \(n\) rows and \(m\) columns. The
cells of the matrix are marked with 0 (water) or 1 (water lily). From one water
lily, Maša can jump to any other water lily in the same row or column. If in the
previous jump Maša changed the column she was in, then in the next jump she
must change the row she is in. If in the previous jump Maša changed the row she
was in, then in the next jump she must change the column she is in. After Maša
jumps from the water lily she is currently on, it sinks and can no longer be jumped on.
Maša likes to have fun and wants to visit a total of 5 water lilies along her path (including the starting
water lily).
Help her and calculate in how many ways she can do this if she can choose any water lily as her starting
point. Two paths are considered different if the positions of their first, second, third, fourth, or fifth water
lilies differ.

제약
입력 형식

The first line contains the natural numbers \(n\) and \(m\) (\(1 \le n\), \(m \le 2000\)), as described in the problem
statement.
In each of the following \(n\) lines there are \(m\) characters, which are either 0 or 1 and represent the cells of
the lake.

출력 형식

Print a single number, the answer to the question from the problem statement.

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

1

8점

n, \(m \le 4\)

2

27점

n, \(m \le 10\)

3

58점

n, \(m \le 400\)

4

17점

No additional constraints.

예제 1
입력
2 3
111
110
출력
4
예제 2
입력
4 4
1111
1111
1111
1111
출력
2304
예제 3
입력
2 5
11110
01111
출력
48
설명

Clarification of the first example: The 4 possible jump paths on water lilies are:
[1, 1] →[2, 1] →[2, 2] →[1, 2] →[1, 3]
[1, 2] →[2, 2] →[2, 1] →[1, 1] →[1, 3]
[1, 3] →[1, 2] →[2, 2] →[2, 1] →[1, 1]
[1, 3] →[1, 1] →[2, 1] →[2, 2] →[1, 2]

문제 정보

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

출처 COCI 2025/2026 Contest 5

평가 및 의견

Pet

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

Log in to rate problems.

개별 의견

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

풀이 제출

Pet

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