포럼
문제 COCI00100

Lubenica

설명

Children in school are having fun instead of listening to the teacher. With their iPhone devices the children throw watermelons at each other on the Facebook social site.

The game started when Goran threw one watermelon at each of his friends during the first class that day. During subsequent classes, all children (including Goran) behaved like this:

  • If they had been hit by an odd number of watermelons during the previous class, they threw exactly one watermelon at each of their friends;
  • If they had been hit by an even number of watermelons (including zero), then they hit each of their friends with two watermelons.

The children are numbered \(1\) through \(N\), Goran obviously being number \(1\). The friend relationships between the children are also known.

Write a program that will calculate the total number of watermelons thrown after \(H\) classes.

제약
입력 형식

The first line contains two integers \(N\) and \(H\) (\(1 \le N \le 20\), \(1 \le H \le 1\,000\,000\,000\)), the number of kids and classes.

Each of the following \(N\) lines contains a string of \(N\) characters 0 or 1. The character \((A, B)\) in this matrix is 1 if children \(A\) and \(B\) are friends. No child will be their own friend. The input matrix will be symmetric.

출력 형식

Output the number of watermelons after \(H\) classes.

Scoring: In test cases worth \(50\%\) of points, \(H\) will be at most \(1000\).

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

Subtask 1

50점

\(H \le 1000\)

Subtask 2

50점

No additional constraints (\(H \le 10^9\)).

예제 1
입력
4 1
0110
1001
1001
0110
출력
2
예제 2
입력
4 2
0110
1001
1001
0110
출력
14
예제 3
입력
5 3
01000
10110
01000
01001
00010
출력
26
문제 정보

riseoj 작성

출처 COCI 2008/2009 Contest 5

평가 및 의견

Lubenica

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

Log in to rate problems.

개별 의견

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

풀이 제출

Lubenica

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