ГлавнаяСборникиТурнирыРазделыФорумыУчастникиПечатьПомощьО системе

Турниры > Bil-273 Учунчу практика 02.10.2019 > задача:


4. Colored hills

Bil-273 Учунчу практика 02.10.2019

Старт: 02.окт.2019 в 14:00:00
Финиш: 02.окт.2019 в 17:00:00
Турнир завершён!
• Турнирная таблица

Задачи турнира

• 1. Big Dance
• 2. Bookshelf
• 3. Coin Game
• 4. Colored hills

Обратная связь

Если у вас есть предложения или пожелания по работе Contester, посетите форум сайта www.contester.ru.

Лимит времени 1000/1000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб.

Problem description

There are N colored hills. Some of them are connected with bridges. We want to paint bridges to the same color with the hills they connect. But it is not always possible (when connected hills have different colors). Calculate number of bridges that can not be painted.

Input

There is a single integer on the first line of input N (1 <= N <= 100), then N lines with N integers (0 - no brige, 1 - connected with bridge, adjacency matrix of graph). In the last line there are N integers from 1 to 3 - colors of hills.

Output

Write number of bridges that can not be painted.

Example

stdin stdout

7
0 1 0 0 0 1 1
1 0 1 0 0 0 0
0 1 0 0 1 1 0
0 0 0 0 0 0 0
0 0 1 0 0 1 0
1 0 1 0 1 0 0
1 0 0 0 0 0 0
1 1 1 1 1 3 3

4

Для отправки решений необходимо выполнить вход.

www.contester.ru