Movatterモバイル変換


[0]ホーム

URL:


AI写作智能体 自主规划任务,支持联网查询和网页读取,多模态高效创作各类分析报告、商业计划、营销方案、教学内容等。广告
# Problem B. Professor Q's Software### Source- [hihoCoder](http://hihocoder.com/contest/mstest2015april/problem/2)### Problem鏃堕棿闄愬埗:10000ms鍗曠偣鏃堕檺:1000ms鍐呭瓨闄愬埗:256MB### 鎻忚堪Professor Q develops a new software. The software consists of N modules whichare numbered from 1 to N. The i-th module will be started up by signal Si. Ifsignal Si is generated multiple times, the i-th module will also be startedmultiple times. Two different modules may be started up by the same signal.During its lifecircle, the i-th module will generate Ki signals: E1, E2, ...,EKi. These signals may start up other modules and so on. Fortunately thesoftware is so carefully designed that **there is no loop in the startingchain of modules**, which means eventually all the modules will be stoped.Professor Q generates some initial signals and want to know how many timeseach module is started.![d](image/562b1c8047ba6.png)### 杈撳叆The first line contains an integer T, the number of test cases. T test casesfollows.For each test case, the first line contains contains two numbers N and M,indicating the number of modules and number of signals that Professor Qgenerates initially.The second line contains M integers, indicating the signals that Professor Qgenerates initially.Line 3~N + 2, each line describes an module, following the format S, K, E1,E2, ... , EK. S represents the signal that start up this module. K representsthe total amount of signals that are generated during the lifecircle of thismodule. And E1 ... EK are these signals.For 20% data, all N, M <= 10For 40% data, all N, M <= 103For 100% data, all 1 <= T <= 5, N, M <= 105, 0 <= K <= 3, 0<= S, E <= 105.**Hint: HUGE input in this problem. Fast IO such as scanf and BufferedReader are recommended.**### 杈撳嚭For each test case, output a line with N numbers Ans1, Ans2, ... , AnsN. Ansiis the number of times that the i-th module is started. In case the answersmay be too large, output the answers modulo 142857 (the remainder of divisionby 142857).鏍蜂緥杈撳叆~~~33 2123 256123 2 456 256456 3 666 111 256256 1 903 1100100 2 200 200200 1 300200 05 111 2 2 32 2 3 43 2 4 54 2 5 65 2 6 7~~~鏍蜂緥杈撳嚭~~~1 1 31 2 21 1 2 3 5~~~

[8]ページ先頭

©2009-2025 Movatter.jp