아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Walk of Length 6

시간 제한1초메모리 제한512 MB

요약
무향 그래프에서 길이 6의 닫힌 보행 중 단순한 6-사이클이 아닌 것의 개수를 센다.
난이도

보통10점 중 6점

유형
조합론, 그래프, 배열
정답자
아직 제출이 없습니다

문제

Bobo has an undirected graph with nn vertices which are conveniently labeled with 1,2,…,n1, 2, \dots, n. Let VV be the set of vertices and EE be the set of edges. He would like to count the number of tuples (v_1,v_2,…,v_6)(v\_1, v\_2, \dots, v\_6) where:

  • v_1,v_2,…,v_6∈Vv\_1, v\_2, \dots, v\_6 \in V,
  • v_1,v_2,v_2,v_3,…,v_5,v_6,v_6,v_1∈E\\{v\_1, v\_2\\}, \\{v\_2, v\_3\\}, \dots, \\{v\_5, v\_6\\}, \\{v\_6, v\_1\\} \in E;
  • C=(v_1,v_2,v_2,v_3,…,v_5,v_6,v_6,v_1)\mathcal{C} = (\\{v\_1, v\_2\\}, \\{v\_2, v\_3\\}, \dots, \\{v\_5, v\_6\\}, \\{v\_6, v\_1\\}) is not a simple cycle of length 66.

입력

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 nn (1≤n≤10001 \leq n \leq 1000). 

The ii-th of the following nn lines contains a string g_ig\_i of length nn where g_i,jg\_{i, j} denotes the existence of edge i,j\\{i, j\\} (g_i,j∈0,1g\_{i, j} \in \\{0, 1\\}, g_i,i=0g\_{i, i} = 0, g_i,j=g_j,ig\_{i, j} = g\_{j, i}). 

It is guaranteed that the sum of nn does not exceed 10001000.

출력

For each test case, output an integer which denotes the number of tuples.

예제1

  1. 예제 1

    입력
    3
    011
    101
    110
    4
    0101
    1010
    0101
    1010
    6
    011111
    101111
    110111
    111011
    111101
    111110
    
    예상 출력
    66
    128
    14910