Submission #112569

# Submission time Handle Problem Language Result Execution time Memory
112569 2019-05-20T16:01:02 Z Kastanda Skyscraper (JOI16_skyscraper) C++11
5 / 100
9 ms 3968 KB
// I am.
#include<bits/stdc++.h>
using namespace std;
const int N = 109, L = 1009, Mod = 1e9 + 7;
int n, l, A[N], dp[N][L][2][2], dpt[N][L][2][2];
inline void Add(int j, int k, int s, int e, int val)
{
    dp[j][k][s][e] += val;
    if (dp[j][k][s][e] >= Mod)
        dp[j][k][s][e] -= Mod;
}
int main()
{
    scanf("%d%d", &n, &l);
    for (int i = 0; i < n; i ++)
        scanf("%d", &A[i]);
    sort(A, A + n);
    dp[1][0][0][0] = dp[1][0][0][1] = 1;
    dp[1][0][1][0] = dp[1][0][1][1] = 1;

    for (int i = 0; i < n - 1; i ++)
    {
        memcpy(dpt, dp, sizeof(dp));
        memset(dp, 0, sizeof(dp));
        for (int j = 1; j <= i + 1; j ++)
            for (int k = 0; k <= l; k ++)
                for (int s = 0; s <= 1; s ++)
                    for (int e = 0; e <= 1; e ++)
                    {
                        int _k = k + (j + j - s - e) * (A[i + 1] - A[i]);
                        if (_k > l)
                            continue;
                        Add(j - 1, _k, s, e, dpt[j][k][s][e] * 1LL * (j - 1) % Mod);
                        Add(j + 1, _k, s, e, dpt[j][k][s][e] * 1LL * (j - 1) % Mod);
                        Add(j, _k, s, e, dpt[j][k][s][e] * 2LL * (j - 1) % Mod);
                        if (!s)
                        {
                            Add(j, _k, 1, e, dpt[j][k][s][e]);
                            Add(j + 1, _k, 1, e, dpt[j][k][s][e]);
                            Add(j, _k, 0, e, dpt[j][k][s][e]);
                            Add(j + 1, _k, 0, e, dpt[j][k][s][e]);
                        }
                        if (!e)
                        {
                            Add(j, _k, s, 1, dpt[j][k][s][e]);
                            Add(j + 1, _k, s, 1, dpt[j][k][s][e]);
                            Add(j, _k, s, 0, dpt[j][k][s][e]);
                            Add(j + 1, _k, s, 0, dpt[j][k][s][e]);
                        }
                    }
    }
    int tot = 0;
    for (int i = 0; i <= l; i ++)
        tot = (tot + dp[1][i][1][1]);
    return !printf("%d\n", tot);
}

Compilation message

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &n, &l);
     ~~~~~^~~~~~~~~~~~~~~~
skyscraper.cpp:16:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &A[i]);
         ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 5 ms 3840 KB Output is correct
3 Correct 6 ms 3712 KB Output is correct
4 Correct 6 ms 3840 KB Output is correct
5 Correct 8 ms 3740 KB Output is correct
6 Correct 8 ms 3712 KB Output is correct
7 Correct 7 ms 3712 KB Output is correct
8 Correct 7 ms 3712 KB Output is correct
9 Correct 8 ms 3712 KB Output is correct
10 Correct 7 ms 3840 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 3712 KB Output is correct
2 Correct 9 ms 3840 KB Output is correct
3 Correct 8 ms 3712 KB Output is correct
4 Correct 8 ms 3712 KB Output is correct
5 Correct 9 ms 3812 KB Output is correct
6 Correct 9 ms 3968 KB Output is correct
7 Correct 5 ms 3712 KB Output is correct
8 Correct 8 ms 3712 KB Output is correct
9 Incorrect 8 ms 3712 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 5 ms 3840 KB Output is correct
3 Correct 6 ms 3712 KB Output is correct
4 Correct 6 ms 3840 KB Output is correct
5 Correct 8 ms 3740 KB Output is correct
6 Correct 8 ms 3712 KB Output is correct
7 Correct 7 ms 3712 KB Output is correct
8 Correct 7 ms 3712 KB Output is correct
9 Correct 8 ms 3712 KB Output is correct
10 Correct 7 ms 3840 KB Output is correct
11 Correct 8 ms 3712 KB Output is correct
12 Correct 9 ms 3840 KB Output is correct
13 Correct 8 ms 3712 KB Output is correct
14 Correct 8 ms 3712 KB Output is correct
15 Correct 9 ms 3812 KB Output is correct
16 Correct 9 ms 3968 KB Output is correct
17 Correct 5 ms 3712 KB Output is correct
18 Correct 8 ms 3712 KB Output is correct
19 Incorrect 8 ms 3712 KB Output isn't correct
20 Halted 0 ms 0 KB -