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

Board Coloring

Time Limit: 10000/10000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)
Total Submission(s): 446    Accepted Submission(s): 146


Problem Description
HH is painting a board of size 4 * N. You can assume the color of square (X, Y) on the board is Ax,y which is an integer between 0 and 255. For the beauty of the board, HH decide to paint the board following the rules :
1) Ax,y >= Ax,y-1.
2) For some given pairs of (X1, Y1) (X2, Y2), AX1,Y1 = AX2,Y2
Your task is to calculate how many ways there are to paint the board.
 

Input
There are multiple test cases, the first line of input contains a single integer denoting the number of test cases.
For each test case, the first line contains an integer N and M, denoting the length of the board and the number of additional rules. (1 <= N <= 15, 0 <= M <= 100)
For next M lines, each line contains four integers X1, Y1, X2, Y2 denoting one additional rule for the painting. (1 <= X1, X2 <= 4, 1 <= Y1, Y2 <= N)
 

Output
For each test cases, you are to output the number of ways of painting. Because there may be too many ways, you are only to output the last five digits. See sample output for further details.
 

Sample Input
3 1 0 1 3 1 1 2 1 1 1 3 1 4 1 3 1 2 6 1 1 2 1 1 1 3 1 1 1 4 1 1 2 2 2 1 2 3 2 1 2 4 2
 

Sample Output
Case 1: 67296 Case 2: 00256 Case 3: 32896
 

Author
HyperHexagon
 

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-11-23 00:11:16, Gzip enabled