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

Colorful Segment

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 419    Accepted Submission(s): 106
Special Judge


Problem Description

Additive color mixing: adding red to green yields yellow; adding red to blue yields magenta; adding green to blue yields cyan; adding all three primary colors together yields white.

In three dimensional space, there are N segments. Their initial color is black. In the red light, they will turn red. In the green light, they will turn green. In the blue light, they will turn blue. In the red and green light, they will turn yellow. In the red and blue light, they will turn magenta. In the green and blue light, they will turn cyan. In the red, green and blue light, they will turn white.

There are M light sources. They can transmit red, green or blue light. But the light they emitted only illuminate a small area. The ith( 1 ¡Ü i ¡Ü M ) light source is located at (xi, yi, zi) and it can illuminate an area of ellipsoidal with equation as follows.


Under irradiation of the M light sources, segments will show a different color. You should calculate the length of the segment in different colors.
 

Input
The first line of the input is T (1 ¡Ü T ¡Ü 100), which stands for the number of test cases you need to solve.

The first line of each case contains two integers N ,M (1 ¡Ü N, M ¡Ü 100), denoting the number of segments and light sources, respectively.

For the next N lines, eac line describes one segment with six integers x1, y1, z1, x2, y2, z2( -10000 ¡Ü x1, y1, z1, x2, y2, z2 ¡Ü 10000) which are coordinates of the segment¡¯s ending.

Then follows M lines. Each line begins with six integers xi, yi, zi, ai, bi, ci as mentioned above (-10000 ¡Ü xi, yi, zi ¡Ü 10000, 1 ¡Ü ai, bi, ci ¡Ü 10000). At the end of the line is a character being ¡®R¡¯,¡®G¡¯ or ¡®B¡¯. ¡®R¡¯ means the light source emits red light. ¡®G¡¯ means the light source emits green light. ¡®B¡¯ means the light source emits blue light.
 

Output
For each test case, you should output 8 lines, output the length of segment with color black, red, green, blue, yellow, magenta, cyan, white in order. See detailed format from the sample output. Answer will be considered as correct if their absolute error is less than 10-5.
 

Sample Input
2 1 2 -5 0 0 5 0 0 0 0 0 2 1 1 R 2 0 0 2 1 1 B 2 3 2 0 0 -2 0 0 0 -3 0 0 5 0 0 0 0 1 2 1 R 0 2 0 1 2 1 G 0 2 0 1 2 1 B
 

Sample Output
4.00000 2.00000 0.00000 2.00000 0.00000 2.00000 0.00000 0.00000 4.00000 4.00000 0.00000 0.00000 0.00000 0.00000 2.00000 2.00000
 

Source
 

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