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

Weather

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 735    Accepted Submission(s): 223


Problem Description
Hovey Chen is going to Azeroth! "I have reached Darnassus." Hovey told Eliane Su, his girlfriend. Each day, Hovey called Eliane, and told her his feeling at Azeroth. "It's a good day today. We are going to hunt some Goblin :)" "It's raining and raining. We can do nothing but sleeping :("
Several days later, Hovey was missing Eliane so much. So he came back to the Earth. He wants to write a travel note for his friends. However, he forgets where he had been! What's worse, he never told Eliane he route. Luckily, he told Eliane the weather in his everyday report, and Eliane wrote it down on her notebook. Hovey knows the probability he went from one place to another. Given the probability from Darnassus to Booty Bay be p, it means that if Hovey is at Darnassus today, the chance he is going to Booty Bay tomorrow is p. Eliane knows the probability of given place to be in given weather. Now given the first place, and the two probability matrices, can you help Hovey to figure out the route which has the greatest probablity.
 

Input
The first line is an integer T£¬ the number of test cases.
In each test cases, the first is three positive integers n, m, w (1 ¡Ü n ¡Ü 1000, 1 ¡Ü m, w ¡Ü 100). Hovey has stayed in Azeroth for n + 1 days. Days are labeled from 0 to n. The number of places in Azeroth is m. The number of weather conditions in Azeroth is w. Hovey was always at Darnassus in day 0, which is place 0.
Then n integers follow, each is in the range of [0, w - 1]. They are weather conditions from day 1 to n.
Then m lines follow, each containing m numbers. The jth number in the ith line is the probabilty from place i to place j. Places are numbered from 0.
Then m lines follow, each containing w numbers. The jth number in the ith line is the probabilty that place i is in weather condition j. Weather conditions are numbered from 0.
 

Output
For each test cases, output n intergers in the range of [0, m - 1] in a line, seperated by a single space, representing the route which has the greatest probability. If there is a tie, output the one with the least lexicographic order, e.g. 2 1 3 is less than 2 3 1.
 

Sample Input
1 3 3 2 1 1 0 0.3 0.5 0.2 0.1 0.2 0.7 0.3 0.3 0.4 0.6 0.4 0.4 0.6 0.3 0.7
 

Sample Output
1 2 0
 

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-05-02 07:58:23, Gzip enabled