2014多校10(1005)hdu4975(网络流isap+判断唯一性)

A simple Gaussian elimination problem.

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 658    Accepted Submission(s): 221


Problem Description
Dragon is studying math. One day, he drew a table with several rows and columns, randomly wrote numbers on each elements of the table. Then he counted the sum of each row and column. Since he thought the map will be useless after he got the sums, he destroyed the table after that.

However Dragon's mom came back and found what he had done. She would give dragon a feast if Dragon could reconstruct the table, otherwise keep Dragon hungry. Dragon is so young and so simple so that the original numbers in the table are one-digit number (e.g. 0-9).

Could you help Dragon to do that?
 

Input
The first line of input contains only one integer, T(<=30), the number of test cases. Following T blocks, each block describes one test case.

There are three lines for each block. The first line contains two integers N(<=500) and M(<=500), showing the number of rows and columns.

The second line contains N integer show the sum of each row.

The third line contains M integer show the sum of each column.
 

Output
Each output should occupy one line. Each line should start with "Case #i: ", with i implying the case number. For each case, if we cannot get the original table, just output: "So naive!", else if we can reconstruct the table by more than one ways, you should output one line contains only: "So young!", otherwise (only one way to reconstruct the table) you should output: "So simple!".
 

Sample Input
    
    
    
    
3 1 1 5 5 2 2 0 10 0 10 2 2 2 2 2 2
 

Sample Output
    
    
    
    
Case #1: So simple! Case #2: So naive! Case #3: So young!

题意:给出n行,m列的和,然后每个格子只能是0~9的数,问你有没有一种填数的方案使得满足给出的数据

思路:这题跟hdu4888基本是一模一样,但这题比较卡时间,网络流dinic,isap都能过,时间卡在最后的判环,只要在找环的时候边dfs边把走过的边删掉就好了

你可能感兴趣的:(ACM,HDU)