Solutions are presented as using the least memory and the fastest execution time. It also takes the top 10 most recent solutions from each language. If you want to limit to a specific index, click the "Solved" button and go to that problem.
ContestId |
Name |
Phase |
Frozen |
Duration (Seconds) |
Relative Time |
Start Time |
|---|---|---|---|---|---|---|
| 45 | School Team Contest 3 (Winter Computer School 2010/11) | FINISHED | False | 18000 | 486673180 | Nov. 13, 2010, 11 a.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 318 ) | B | School | PROGRAMMING | dp dsu | 2400 |
There are n students studying in the 6th grade, in group "B" of a berland secondary school. Every one of them has exactly one friend whom he calls when he has some news. Let us denote the friend of the person number i by g ( i ) . Note that the friendships are not mutual, i.e. g ( g ( i )) is not necessarily equal to i . On day i the person numbered as a i learns the news with the rating of b i ( b i ≥ 1 ). He phones the friend immediately and tells it. While he is doing it, the news becomes old and its rating falls a little and becomes equal to b i - 1 . The friend does the same thing — he also calls his friend and also tells the news. The friend of the friend gets the news already rated as b i - 2 . It all continues until the rating of the news reaches zero as nobody wants to tell the news with zero rating. More formally, everybody acts like this: if a person x learns the news with a non-zero rating y , he calls his friend g ( i ) and his friend learns the news with the rating of y - 1 and, if it is possible, continues the process. Let us note that during a day one and the same person may call his friend and tell him one and the same news with different ratings. Thus, the news with the rating of b i will lead to as much as b i calls. Your task is to count the values of res i — how many students learned their first news on day i . The values of b i are known initially, whereas a i is determined from the following formula: The first line contains two space-separated integers n and m ( 2 ≤ n , m ≤ 10 5 ) — the number of students and the number of days. The second line contains n space-separated integers g ( i ) ( 1 ≤ g ( i ) ≤ n , g ( i ) ≠ i ) — the number of a friend of the i -th student. The third line contains m space-separated integers v i ( 1 ≤ v i ≤ 10 7 ). The fourth line contains m space-separated integers b i ( 1 ≤ b i ≤ 10 7 ). Print m lines containing one number each. The i -th line should contain res i — for what number of students the first ne |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 194974 | Sereja | B | Nov. 13, 2010, 3:50 p.m. | OK | Delphi | TESTS | 105 | 80 | 13004800 | 2400 | |
| 194576 | tourist | B | Nov. 13, 2010, 3:07 p.m. | OK | Delphi | TESTS | 105 | 80 | 32563200 | 2400 | |
| 194575 | tourist | B | Nov. 13, 2010, 3:07 p.m. | OK | Delphi | TESTS | 105 | 90 | 32563200 | 2400 | |
| 194148 | ZumZoom taras.klaskovsky iRomchig | B | Nov. 13, 2010, 2:21 p.m. | OK | FPC | TESTS | 105 | 90 | 260608000 | 2400 | |
| 194737 | zpl1 chensqi plokzfadai | B | Nov. 13, 2010, 3:25 p.m. | OK | GNU C | TESTS | 105 | 140 | 7475200 | 2400 | |
| 191626 | free0u kreep | B | Nov. 13, 2010, 11:40 a.m. | OK | GNU C++ | TESTS | 105 | 140 | 2969600 | 2400 | |
| 193790 | AlTimin JOZHEG fadeevs | B | Nov. 13, 2010, 1:49 p.m. | OK | GNU C++ | TESTS | 105 | 140 | 5939200 | 2400 | |
| 194405 | Matt lala C.sis | B | Nov. 13, 2010, 2:49 p.m. | OK | GNU C++ | TESTS | 105 | 220 | 7782400 | 2400 | |
| 194571 | PavelKunyavskiy slavik Babanin_Ivan | B | Nov. 13, 2010, 3:06 p.m. | OK | GNU C++ | TESTS | 105 | 360 | 52428800 | 2400 | |
| 193226 | xiaoyoulei zlly 19910517 | B | Nov. 13, 2010, 1:10 p.m. | OK | MS C++ | TESTS | 105 | 140 | 3072000 | 2400 |
Back to search problems