Diferente pentru problema/christmas-balls intre reviziile #2 si #8

Nu exista diferente intre titluri.

Diferente intre continut:

== include(page="template/taskheader" task_id="christmasballs") ==
== include(page="template/taskheader" task_id="christmas-balls") ==
Christmas is coming, and Alessandro has to decorate his living room with a Christmas tree.
h2. Date de intrare
The first line of the input file $christmasballs.in$ contains the only integer $N$ ($1 \le N \le 10^5$), the number of nodes of the tree.
The first line of the input file $christmas-balls.in$ contains the only integer $N$, $1 ≤ N ≤ 10^5$, the number of nodes of the tree.
The second line contains $N$ integers $C_i$ ($0 &le; C_i < N$), the colors of each ball.
The second line contains $N$ integers $C_i$ $0 &le; C_i < N$, the colors of each ball.
The third line contains $N-1$ integers: $P_i$ (with $1 &le; i < N$) is the index of the parent of the $i$-th node.
For tests worth $13$ points, the tree is a line.
 
For tests worth $15$ more points, ($1 &le; N &le; 1000$), ($1 &le; MAXC &le; 2$).
 
For tests worth $21$ more points, ($1 &le; N &le; 1000$).
 
For tests worth $17$ more points, ($1 &le; MAXC &le; 2$).
 
h2. Date de ieşire
The output file $christmas-balls.out$ contains a single line with an integer: chosen the optimal subtree, the number of colors with the highest frequency.
h2. Restrictii
 
* For tests worth $13$ points, the tree is a line.
* For tests worth $15$ more points, $1 &le; N &le; 1000$, $1 &le; MAXC &le; 2$.
* For tests worth $21$ more points, $1 &le; N &le; 1000$.
* For tests worth $17$ more points, $1 &le; MAXC &le; 2$.
* The scores obtained now may be different compared to the ones from the original contest
 
h2. Exemplu
table(example). |_. christmasballs.in |_. christmasballs.out |
table(example). |_. christmas-balls.in |_. christmas-balls.out |
| 8
1 2 0 2 0 0 1 1
0 0 1 1 3 4 4
| 3
|
table(example). |_. christmasballs.in |_. christmasballs.out |
table(example). |_. christmas-balls.in |_. christmas-balls.out |
| 5
0 1 1 0 0
0 1 2 3
In the second sample case the tree forms a line with $5$ nodes. The optimal solution is to cut the subtree rooted at node $1$. The most frequent color appears with $2$ balls, and there are $2$ colors with that many balls.
== include(page="template/taskfooter" task_id="christmasballs") ==
== include(page="template/taskfooter" task_id="christmas-balls") ==

Nu exista diferente intre securitate.

Topicul de forum nu a fost schimbat.