F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Problem F

Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 4    Accepted Submission(s): 1


Problem Description
A social network is a social structure made up of a set of social actors (such as individuals or organizations) and a set of the relationships between these actors. In simple cases, we may represent people as nodes in a graph, and if two people are friends, then an edge will occur between two nodes.


Figure 1: C knows every one, while D only knows C in this social network.


There are many interesting properties in a social network. Recently, we are researching on the Social Butterfly in the network. A Social Butterfly should satisfy the following conditions:

1. She is a female;
2. She knows at least $K$ male friends.

Now we have already taken out several networks from database, but since the data only contain nodes and edges, we don't know whether a node represents a male or a female. We are interested, that if there are equal probabilities for a node to be male and female (each with 1/2 probability), what will be the xpectation of number of social butterflies in the network?
 

Input
The number of test cases T (T <= 10^4) will occur in the first line of input.

For each test case:

The first line contains the number of nodes $N (1 \leq N \leq 30)$ and the parameter $K (0 \leq K \lt N)$.

Then an $N \times N$ matrix $G$ followed, where $G_{ij} = 1$ denotes $j$ is a friend of $i$, otherwise $G_{ij} = 0$. Here, it's always satisfied that $G_{ii} = 0$ and $G_{ij} = G_{ji}$ for all $1 \leq i, j \leq N$.
 

Output
For each test case, output the expectation of number of social butterflies in 3 decimals.
 

Sample Input
2 2 1 0 1 1 0 3 1 0 1 1 1 0 1 1 1 0
 

Sample Output
0.500 1.125
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2025 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2025-03-29 18:08:20, Gzip enabled