Spheres

All submissions for this problem are available.
Read problems statements in Mandarin Chinese and Russian
Eugene has a sequence of upper hemispheres and another of lower hemispheres. The first set consists of N upper hemispheres indexed 1 to N and the second has M lower hemispheres indexed 1 to M. The hemispheres in any sequence can have different radii.
He is now set out on building spheres using them. To build a sphere of radius R, he must take one upper half of the radius R and one lower half of the radius R. Also, he can put a sphere into a bigger one and create a sequence of nested concentric spheres. But he can't put two or more spheres directly into another one.
Examples:
If there is a sequence of (D+1) nested spheres, we can call this sequence as a Dsequence.
Eugene has to find out how many different Xsequence are possible (1 <= X <= C). An X sequence is different from another if the index of any of the hemisphere used in one Xsequence is different from the other. Eugene doesn't know how to do it, so Chef agreed to help him. Of course, Chef is too busy now and he asks you to help him.
Input
The first line contains a three integers: N denoting the number of upper sphere halves, M denoting the number of lower sphere halves and C.
The second line contains N spaceseparated integers U_{1}, U_{2}, ..., U_{N} denoting the radii of upper hemispheres.
The third line contains M spaceseparated integers L_{1}, L_{2}, ..., L_{M} denoting the radii of lower hemispheres.
Output
Output a single line containing C spaceseparated integers D_{1}, D_{2}, ..., D_{C}, where D_{i} is the number of ways there are to build isequence in modulo 10^{9}+7.
Constraints
 1 ≤ N ≤ 10^{5}
 1 ≤ M ≤ 10^{5}
 1 ≤ C ≤ 10^{3}
 1 ≤ U_{i} ≤ C
 1 ≤ L_{i} ≤ C
Subtasks
 Subtask 1: 1 ≤ N, M, C ≤ 10  15 points
 Subtask 2: 1 ≤ N, M, C ≤ 100  25 points
 Subtask 3: Original constraints  60 points
Example
Input: 3 4 3 1 2 3 1 1 3 2 Output: 5 2 0
Explanation
We can build spheres with such radii:
R=1 and there are 2 ways to do it. (We can choose any of 2 lower hemispheres with R=1)
R=2 and there is 1 way to do it.
R=3 and there is 1 way to do it.
We can build these 1sequences:
1>2 and there are 2 ways to do it. ( sphere with radius 1 is inside sphere with radius 2, we can choose any of 2 ways of building sphere with radius 1)
1>3 and there are 2 ways to do it.
2>3 and there is 1 way to do it.
2 + 2 + 1 = 5
We can build these 2sequences:
1>2>3 and there are 2 ways to do it.
We can't build 3sequences, because we don't have 4 spheres of different radii.
Author:  aangairbender 
Editorial  http://discuss.codechef.com/problems/KSPHERES 
Tags  aangairbender, dynamicprogramming, easy, oct15 
Date Added:  29072015 
Time Limit:  0.5 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions