제출 #1203236

#제출 시각아이디문제언어결과실행 시간메모리
1203236SSKMFCalvinball championship (CEOI15_teams)C++20
10 / 100
1 ms784 KiB
#include <bits/stdc++.h>
using namespace std;

const int mod(1000007);
int sir[10001] , combinari[101][101] , stirling[101][101] , factorial[101] , putere[101];
bool gasit[10001];

int main ()
{
    ios :: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    int lungime;
    cin >> lungime;

    combinari[0][0] = stirling[0][0] = factorial[0] = putere[0] = 1;
    for (int total = 1 ; total <= lungime ; total++)
    {
        combinari[total][0] = 1;
        putere[total] = 2LL * putere[total - 1] % mod;
        factorial[total] = 1LL * factorial[total - 1] * total % mod;
        for (int componente = 1 ; componente <= total ; componente++) 
        { 
            combinari[total][componente] = (combinari[total - 1][componente - 1] + combinari[total - 1][componente]) % mod;
            stirling[total][componente] = (stirling[total - 1][componente - 1] + 1LL * stirling[total - 1][componente] * componente) % mod;
        }
    }

    int rezultat = 1;
    for (int indice = 1 , maxim = 0 , luat = 0 ; indice <= lungime ; indice++)
    {
        int valoare;
        cin >> valoare;

        for (int dat = 1 ; dat < valoare ; dat++)
        {
            int factor = 0;
            const int ramas = max(dat , maxim) - luat - (gasit[dat] ? 0 : 1);
            for (int total = ramas ; total <= lungime - indice ; total++)
            {
                if (total - ramas <= luat + (gasit[dat] ? 0 : 1)) {
                    if ((factor += combinari[luat + (gasit[dat] ? 0 : 1)][total - ramas]) >= mod)
                        { factor -= mod; }
                }

                if ((rezultat += 1LL * stirling[lungime - indice][total] * factorial[total] % mod * factor % mod) >= mod)
                    { rezultat -= mod; }
            }
        }
        
        if (!gasit[valoare])
        {
            maxim = max(maxim , valoare);
            gasit[valoare] = true;
            luat++;
        }
    }

    cout << rezultat;
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...