Logo
(追記) (追記ここまで)

11061번 - Awkward Group 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
5 초 256 MB147463730.833%

문제

A community P consists of n persons living in a small town. The persons in P may have friendly relationship with someone, but there are men whom they have never met. A closeness between any distinct persons x and y of P is expressed by a value f(x,y). Here it is assumed that f(x,y) = f(y,x)

A group F of persons in P, that is, a subset of P, is called an awkward group if the number of persons in F, denoted by |F|, is equal to neither n nor 1 and the maximum closeness between any two distinct persons in F is strictly less than any closeness between a person in F and one not in F, that is, if F satisfies the following conditions:

1 < |F| < n and max{ f(x,y) | x ≠ y, x ∈ F, y ∈ F } < min{ f(x',y') | x' ∈ F, y' ∈ P - F}.

Given the values f(x,y) for any distinct person x and y in P, your program is to find the number of all the possible awkward groups of P.

For example, there are three persons x, y, and z in a community P. The groups F of P such that 1 < |F| < 3 are {x,y}, {y,z}, and {z,x}. The values for the closeness between two persons are given as f(x,y) = 8, f(y,z) = 3, and f(z,x) = 5. Then the awkward group among the candidates is only {y,z}. So the number of all the possible awkward groups of P is 1.

입력

Your program is to read from standard input. The input consists of T test cases. The number of test cases T is given in the first line of the input. Each test case starts with a line containing an integer, n (1 ≤ n ≤ 1,000), where n is the number of persons in the community P. The persons are represented by integers 1 to n. In the following n-1 lines, the values hij of the closeness are given. In the ith line, there are n-i integers hii+1, hii+2, ..., hin separated by a single space, where hij, j = i+1, ..., n, are the values f(i,j) of the closeness between two persons i and j (1 ≤ i < j ≤ n and 1 ≤ hij ≤ 106).

출력

Your program is to write to standard output. Print exactly one line for each test case. The line should contain an integer representing the number of all the possible awkward groups of P.

제한

예제 입력 1

3
3
8 5
3
4
1 3 5
6 4
2
5
1 6 5 10
7 8 9
2 4
3

예제 출력 1

1
2
3

힌트

출처

ICPC > Regionals > Asia Pacific > Korea > Nationwide Internet Competition > Daejeon Nationalwide Internet Competition 2015 A번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /