ENG  RUSTimus Online Judge
Online Judge
Online contests
About Online Judge
Frequently asked questions
Site news
Problem set
Submit solution
Judge status
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests

Ural Regional School Programming Contest 2014

About     Problems     Submit solution     Judge status     Standings
Contest is over

A. Adventure Time

Time limit: 1.0 second
Memory limit: 64 MB
‘Here’s for you!’ shouted Finn fighting the Shadow Guardians. ‘Jake! Collect the Darkness Rocks and let’s run from here!’
Jake would have been glad to finish as soon as possible, because it was wet and sad in the Dangerous Cave, but it was not so easy to gather Rocks. So he called BMO and asked him to help with choosing an optimal set of Rocks. Jake told BMO that there were n Rocks in the Cave, and they were numbered with different integers from 1 to n. Each Rock was painted one of 26 colors. Jake also reminded BMO of Princess Bubblegum’s warning: there should be at most k Rocks of pairwise different colors among the Rocks taken from the Cave. Only a set of Rocks with this property is safe. If one takes an unsafe set of Rocks from the Cave, Cosmic Evil will be awakened! Of course, Jake doesn’t want to awaken the Evil, but he wants to take as many Darkness Rocks from the Cave as possible. Help BMO to find the size of the largest safe set of Rocks and the number of different safe sets of this size. Two sets of Rocks are different if one of them contains a Rock with a number that is not contained in the other set.


The first line contains n lowercase English letters (1 ≤ n ≤ 105); each letter denotes the color of a Rock. In the second line you are given the integer k (1 ≤ k ≤ 26).


Output two integers separated with a space: the size of the largest safe set of Darkness Rocks and the number of different safe sets of this size.


1 5
5 1
Problem Author: Nikita Sivukhin
Problem Source: Ural Regional School Programming Contest 2014
To submit the solution for this problem go to the Problem set: 2024. Adventure Time