Walk of Length 6
시간 제한1초메모리 제한512 MB
무향 그래프에서 길이 6의 닫힌 보행 중 단순한 6-사이클이 아닌 것의 개수를 센다.
문제
Bobo has an undirected graph with vertices which are conveniently labeled with . Let be the set of vertices and be the set of edges. He would like to count the number of tuples where:
- ,
- ;
- is not a simple cycle of length .
입력
The input contains zero or more test cases, and is terminated by end-of-file. For each test case:
The first line contains an integer ().
The -th of the following lines contains a string of length where denotes the existence of edge (, , ).
It is guaranteed that the sum of does not exceed .
출력
For each test case, output an integer which denotes the number of tuples.