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.
If there is a sequence of (D+1) nested spheres, we can call this sequence as a D-sequence.
Eugene has to find out how many different X-sequence are possible (1 <= X <= C). An X sequence is different from another if the index of any of the hemisphere used in one X-sequence 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.
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 space-separated integers U1, U2, ..., UN denoting the radii of upper hemispheres.
The third line contains M space-separated integers L1, L2, ..., LM denoting the radii of lower hemispheres.
Output a single line containing C space-separated integers D1, D2, ..., DC, where Di is the number of ways there are to build i-sequence in modulo 109+7.
- 1 ≤ N ≤ 105
- 1 ≤ M ≤ 105
- 1 ≤ C ≤ 103
- 1 ≤ Ui ≤ C
- 1 ≤ Li ≤ C
- Subtask 1: 1 ≤ N, M, C ≤ 10 - 15 points
- Subtask 2: 1 ≤ N, M, C ≤ 100 - 25 points
- Subtask 3: Original constraints - 60 points
Input: 3 4 3 1 2 3 1 1 3 2 Output: 5 2 0
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 1-sequences:
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 2-sequences:
1->2->3 and there are 2 ways to do it.
We can't build 3-sequences, because we don't have 4 spheres of different radii.
|Tags||aangairbender, dynamic-programming, easy, oct15|
|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, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.