伙计们这是个问题

在锦标赛中,N名球员恰好相互比赛一次 . 每场比赛都会导致任何一名球员获胜 . 没有关系 . 你已经给出了一张记分卡,其中包含了比赛结束时每位球员的得分 . 玩家的得分是玩家在锦标赛中赢得的总游戏数 . 但是,某些玩家的得分可能已从记分卡中删除 . 有多少可能的记分卡与输入记分卡一致?

输入:第一行包含案例数T.T案例如下 . 每个案例包含第一行的数字N,后面是第二行的N个数字 . 第i个数字表示s_i,即第i个玩家的得分 . 如果第i个玩家的得分已被删除,则表示为-1 .

输出:输出T行,包含每种情况的答案 . 输出每个结果模1000000007 .

I have reduced it to the above form of the question but it is failing on large inputs . 这开始让我头疼 . 任何帮助将不胜感激 . 我有以下代码..我错过了任何角落案件 .

#include<stdio.h>
    long long  solutionMatrix[781][41];
      long long
    noOfWays (int gamesUndecided, int inHowMany, int noOfPlayers)
    {
      if (inHowMany > 0 && gamesUndecided >= 0)
      {
        int i;
        long long result;
        for (i = noOfPlayers - 1, result = 0; i >= 0; i--)
        {
          if((gamesUndecided-i)>=0)
          {
            if (solutionMatrix[gamesUndecided - i][inHowMany - 1] == -1)
              solutionMatrix[gamesUndecided - i][inHowMany - 1] = noOfWays (gamesUndecided - i, inHowMany - 1, noOfPlayers);
            result += solutionMatrix[gamesUndecided - i][inHowMany - 1];
            result %=1000000007L;
          }
        }
        return result%1000000007L;
      }
      else
        return (inHowMany == 0 && gamesUndecided == 0) ? 1 : 0;
    }

      long long
    possibleCards (int score[], int noOfPlayers)
    {
      int i;
      int maxGames = (noOfPlayers * (noOfPlayers - 1)) / 2;
      int sumOfGames = 0, unDecided = 0;
      for (i = 0; i < noOfPlayers; i++)
      {
        if (score[i] != -1)
        {
          if (score[i] >= 0 && score[i] <= noOfPlayers - 1)
          {
            sumOfGames += score[i];
          }
          else
            return 0;
        }
        else
          unDecided++;
      }
      if (sumOfGames > maxGames || (unDecided==0 && sumOfGames < maxGames))
        return 0;
      if (sumOfGames==maxGames && unDecided==0)
        return 1;
      else
      {
        int j;
        for (i = 0; i < 781; i++)
          for (j = 0; j < 41; j++)
            solutionMatrix[i][j] = -1;
        return noOfWays (maxGames - sumOfGames, unDecided, noOfPlayers)%1000000007L;
      }
    }

      int
    main ()
    {
      int noOfTestCases;
      int score[41];
      printf("%u\n",0xffffffff);
      scanf ("%d", &noOfTestCases);
      for (; noOfTestCases > 0; noOfTestCases--)
      {
        int noOfPlayers;
        scanf ("%d", &noOfPlayers);
        int i;
        for (i = 0; i < noOfPlayers; i++)
        {
          scanf ("%d", score + i);
        }
        printf ("%lld\n", possibleCards (score, noOfPlayers));
      }
      return 0;
    }