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

Count the Grid

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


Problem Description
You get a grid of h rows and w columns. Rows are numbered 1, 2, 3, ... , h from top to bottom while columns are numbered 1, 2 , 3, ... , w from left to right. Each cell can be represented by a pair of numbers (x, y), which means this cell is located at row x column y.
You fill the every cell with an integer ranging from 1 to m.
Then you start to play with the gird. Every time you chose a rectangle whose upper left cell is (x1, y1) and lower right cell is (x2, y2), finally you calculate the maximum value v of this rectangle.
After you played n times, you left. When you return, you find that the grid is disappeared. You only remember n rectangles and their corresponding maximum value. You are wondering how many different gird can satisfy your memory. Two grids are different if there is a cell filled different integer.
Give your answer modulo ($10^9 + 7$).
Your memory may have some mistakes so that no grid satisfies it, in this case just output 0.
 

Input
Multiple test cases. In the first line there is an integer T, indicating the number of test cases. For each test case. First line contain 4 integers h, w, m, n. Next are n lines, each line contain 5 integers x1, y1, x2, y2, v.
($T = 55, 1 \leq h, w, m \leq 10^4, 1 \leq x1 \leq x2 \leq h,1 \leq y1 \leq y2 \leq w,1 \leq v \leq m,1 \leq n \leq10$, there are i test cases for n = i)
 

Output
For each test case, please output one line. The output format is "Case #x: ans", x is the case number, starting from 1.
 

Sample Input
2 3 3 2 2 1 1 2 2 2 2 2 3 3 1 4 4 4 4 1 1 2 3 3 2 3 4 4 2 2 1 4 3 2 1 2 3 4 4
 

Sample Output
Case #1: 28 Case #2: 76475
 

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-06-23 10:04:03, Gzip enabled