• Loading...

Problem 1: Auction Ceremony

Points:

Small Case: 10 Answer: 266

Large Case: 25 Answer: 49306943

In the Indian Premier League Auction, there are N players and N team-owners. The owners get the chance to select in order {1,2,...,N}.
At each owners turn, he can either buy a non-selected player, or re-buy a player selected by someone else with value greater than its previous cost.
If an owner buys a player already bought by some other owner, the losing owner immediately gets the chance to select next.
According to rules, each player can be re-bought maximum of T times(bought maximum of T+1 times) and every owner must get at least one player.

For e.g. for T=1 and N=3, with owners (x,y,z) and players (1,2,3), selections can be made in seven ways as:


x1, y2, z3
x1, y2, z1, x3
x1, y2, z1, x2, y3
x1, y2, z2, y3
x1, y2, z2, y1, x3
x1, y1, x2, z3
x1, y1, x2, z3
x1, y1, x2, z2, x3

You can assume players are same and their order does not matter, For example: x1,y2,z3 and x2,y1,z3 are same cases

You need to output the number of ways modulo 100000007

Given the values of N and T, what is the number of ways in which this can be done?

Small Case: N= 5, T=1
Large Case: N= 51, T=8


Solution:

We know that t-restricted stirling number S2t(n,k) of second kind is defined as the number of partitions of {1, . . . , n} into k blocks of size at most t.

For t>=0 and n>=0, number of scenatios with (n+1) buyers and (n+1) players is given by:

Reference: David Applegate and N. J. A. Sloane, The Gift Exchange Problem, AT&T Shannon Labs, 1990,Theorem 1


Code:


#include <stdio.h>
#include <string.h>
#define mod 100000007

long long E[100][1000], t;

long long nCr(long long n, long long r)
{
  if(n<r)
    return 0;
  if(n-r<r)
    r=n-r;
  long long res=1,min=n-r;
  while(n>min && r>1)
  {
    res *= n;
    n--;
    if(res%r==0)
      while(res%r==0 && r>1)
      { 
        res/=r;
        r--;
      }
  }
  if(n>min)
    while(n>min)
    {  res *= n;n--;}
  if(r>1)
  {
    res/=r;
    r--;
  }
  return res;
}

long long E_Cal(long long n, long long k)
{
  int i;
  if(E[n][k]==-1)
  {
    E[n][k]=0;
    if(k>=n && k<=(t+1)*n)
    {
      for(i=0;i<=t;i++)
      {
        E[n][k] = (E[n][k] + ((nCr(k-1,i)%mod) * (E_Cal(n-1,k-1-i)%mod))%mod)%mod;
      }
    }
  }
  return E[n][k];
}

int main()
{
  int n,k;
  long long sum=0;
  scanf("%d%lld",&n,&t);
  n--;
  memset(E,-1,sizeof(E));
  E[0][0]=1;
  for(k=n;k<=(t+1)*n;k++)
    sum = (sum + E_Cal(n,k))%mod;
  printf("%lld\n",sum);
}

Submit your solution

You need to be logged in to submit a solution.

discussions


KoenBig number
Q:The answer to the large case is quite big, do we need a modulo?
A:Problem statement has been updated
shivamlearningsome cases not listed
Q:why following cases are not listed for t=1 and n=3?:x1, y1, x3,z3,x2 and x1,y1,x3,z2. if you are only looking for the distinct number of final selections then why these two combinations are included in same question:x1, y2, z2, y1, x3 and x1, y1, x2, z2, x3
A:As already explained, order of players don\'t matter but order of buyers does matter. For x1, y1, x3,z3,x2, matches x1, y1, x2, z2, x3 in our example, while x1,y1,x3,z2, matches x1, y1, x2, z3. For x1, y2, z2, y1, x3 and x1, y1, x2, z2, x3, they are two different orders.
sinanis there 7 ways or more for T=1 N=3?
Q:For example the following is not listed:x1, y1, x2, z1, y3
A:Yes, there are only 7 ways. In your solution, in case z1, player-1 has been re-bought 2nd time, which is not allowed
arpoQuestion 1
Q:At time i is it possible for buyer i to buy a player whose number is greater than i?
A:Yes! Buyers get chance in order {1,2,...,n}, while the player they chose has no restriction on order. Anyone can chose any player

post a question

Loading...

Problem 1
Problem 2
Problem 3
Problem 4
Problem 5 (bonus) Expired
Problem 1
Problem 2
Problem 3
Problem 4 (bonus) Expired
Top Scorers
rng_58 235
Anton_Lunyov 225
tourist 190
Silence 180
cedricl2 175
cgy4ever 175
DrKorbin 165
Koen 155
bbbasic 150
lunae_2 150
Submissions
Problem 1
10 pt
not submitted
98
submissions

19
correct (19 %)



25 pt
not submitted
2
submissions

1
correct (50 %)


Problem 2
5 pt
not submitted
95
submissions

38
correct (40 %)



10 pt
not submitted
19
submissions

15
correct (78 %)


Problem 3
5 pt
not submitted
153
submissions

117
correct (76 %)



15 pt
not submitted
44
submissions

25
correct (56 %)


Problem 4
10 pt
not submitted
152
submissions

54
correct (35 %)



15 pt
not submitted
23
submissions

10
correct (43 %)


Problem 5
10 pt
not submitted
36
submissions

28
correct (77 %)



20 pt
not submitted
6
submissions

2
correct (33 %)


Problem 6
5 pt
not submitted
41
submissions

29
correct (70 %)



10 pt
not submitted
15
submissions

14
correct (93 %)


Problem 7
5 pt
not submitted
38
submissions

17
correct (44 %)



10 pt
not submitted
16
submissions

15
correct (93 %)


Problem 8
5 pt
not submitted
127
submissions

104
correct (81 %)



15 pt
not submitted
47
submissions

34
correct (72 %)


Problem 9
5 pt
not submitted
86
submissions

35
correct (40 %)



15 pt
not submitted
16
submissions

15
correct (93 %)


Problem 10
5 pt
not submitted
45
submissions

23
correct (51 %)



15 pt
not submitted
15
submissions

14
correct (93 %)


Problem 11
5 pt
not submitted
81
submissions

27
correct (33 %)



15 pt
not submitted
8
submissions

3
correct (37 %)


Problem 12
5 pt
not submitted
104
submissions

88
correct (84 %)



10 pt
not submitted
31
submissions

21
correct (67 %)