Submission #487101

# Submission time Handle Problem Language Result Execution time Memory
487101 2021-11-14T08:53:56 Z stefantaga Skyscraper (JOI16_skyscraper) C++14
100 / 100
131 ms 19260 KB
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int v[105];
int din[105][105][1005][2][2],n,l,i,j,sum,S,F;
int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(0);
    #ifdef HOME
    ifstream cin("date.in");
    ofstream cout("date.out");
    #endif // HOME
    cin>>n>>l;
    for (i=1;i<=n;i++)
    {
        cin>>v[i];
    }
    sort (v+1,v+n+1);
    /// starile initiale
    din[1][0][0][1][1] = din[1][0][0][0][1] = din[1][0][0][1][0] = din[1][0][0][0][0] = 1;
    for (i=1;i<n;i++)
    {
        for (j=0;j<=n;j++)
        {
            for (sum=0;sum<=l;sum++)
            {
                for (S=0;S<=1;S++)
                {
                    for (F=0;F<=1;F++)
                    {
                        int nou_sum=sum+(v[i+1]-v[i])*(2*j+F+S);
                        if (din[i][j][sum][S][F]==0)
                        {
                            continue;
                        }
                        if (nou_sum>l)
                        {
                            continue;
                        }
                        if (j-1>=0)
                        {
                            din[i+1][j-1][nou_sum][S][F]=(din[i+1][j-1][nou_sum][S][F]+(1LL*din[i][j][sum][S][F]*j)%MOD)%MOD;
                        }
                        din[i+1][j][nou_sum][S][F]=(din[i+1][j][nou_sum][S][F]+(1LL*din[i][j][sum][S][F]*j*2)%MOD)%MOD;
                        din[i+1][j+1][nou_sum][S][F]=(din[i+1][j+1][nou_sum][S][F]+(1LL*din[i][j][sum][S][F]*j)%MOD)%MOD;
                        if (S==1)
                        {
                            din[i+1][j+1][nou_sum][0][F]=(din[i+1][j+1][nou_sum][0][F]+din[i][j][sum][S][F])%MOD;
                            din[i+1][j+1][nou_sum][1][F]=(din[i+1][j+1][nou_sum][1][F]+din[i][j][sum][S][F])%MOD;
                            din[i+1][j][nou_sum][0][F]=(din[i+1][j][nou_sum][0][F]+din[i][j][sum][S][F])%MOD;
                            din[i+1][j][nou_sum][1][F]=(din[i+1][j][nou_sum][1][F]+din[i][j][sum][S][F])%MOD;
                        }
                        if (F==1)
                        {
                            din[i+1][j+1][nou_sum][S][0]=(din[i+1][j+1][nou_sum][S][0]+din[i][j][sum][S][F])%MOD;
                            din[i+1][j+1][nou_sum][S][1]=(din[i+1][j+1][nou_sum][S][1]+din[i][j][sum][S][F])%MOD;
                            din[i+1][j][nou_sum][S][0]=(din[i+1][j][nou_sum][S][0]+din[i][j][sum][S][F])%MOD;
                            din[i+1][j][nou_sum][S][1]=(din[i+1][j][nou_sum][S][1]+din[i][j][sum][S][F])%MOD;
                        }
                    }
                }
            }
        }
    }
    long long solfin=0;
    for (sum=0;sum<=l;sum++)
    {
        solfin=(solfin+din[n][0][sum][0][0])%MOD;
    }
    cout<<solfin;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 1 ms 460 KB Output is correct
10 Correct 1 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 588 KB Output is correct
2 Correct 1 ms 588 KB Output is correct
3 Correct 1 ms 588 KB Output is correct
4 Correct 1 ms 588 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 588 KB Output is correct
7 Correct 1 ms 540 KB Output is correct
8 Correct 1 ms 588 KB Output is correct
9 Correct 1 ms 716 KB Output is correct
10 Correct 1 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 1 ms 460 KB Output is correct
10 Correct 1 ms 460 KB Output is correct
11 Correct 1 ms 588 KB Output is correct
12 Correct 1 ms 588 KB Output is correct
13 Correct 1 ms 588 KB Output is correct
14 Correct 1 ms 588 KB Output is correct
15 Correct 1 ms 460 KB Output is correct
16 Correct 1 ms 588 KB Output is correct
17 Correct 1 ms 540 KB Output is correct
18 Correct 1 ms 588 KB Output is correct
19 Correct 1 ms 716 KB Output is correct
20 Correct 1 ms 588 KB Output is correct
21 Correct 2 ms 1228 KB Output is correct
22 Correct 104 ms 19260 KB Output is correct
23 Correct 127 ms 7192 KB Output is correct
24 Correct 114 ms 10512 KB Output is correct
25 Correct 131 ms 8304 KB Output is correct
26 Correct 110 ms 7744 KB Output is correct
27 Correct 43 ms 8960 KB Output is correct
28 Correct 53 ms 10688 KB Output is correct
29 Correct 94 ms 14012 KB Output is correct
30 Correct 125 ms 8372 KB Output is correct