Submission #57209

# Submission time Handle Problem Language Result Execution time Memory
57209 2018-07-14T09:26:42 Z imeimi2000 Skyscraper (JOI16_skyscraper) C++17
15 / 100
5 ms 1232 KB
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;

const int mod = 1e9 + 7;

int n, l;
int a[101];
int dp[101][101][1001][2][2];

void add(int i, int j, int k, int d, int a, int b, llong p) {
    k += ((j << 1) + a + b) * d;
    if (j < 0) return;
    if (l < k) return;
    dp[i][j][k][a][b] += p % mod;
    dp[i][j][k][a][b] %= mod;
}
int main() {
    scanf("%d%d", &n, &l);
    for (int i = 0; i < n; ++i) {
        scanf("%d", a + i);
    }
    sort(a, a + n);
    dp[0][0][0][0][0] = 1;
    for (int i = 0; i + 1 < n; ++i) {
        int d = a[i + 1] - a[i];
        for (int j = 0; j <= i; ++j) {
            for (int k = 0; k <= l; ++k) {
                llong v;
                //0 0
                v = dp[i][j][k][0][0];
                add(i + 1, j, k, d, 1, 0, v);
                add(i + 1, j, k, d, 0, 1, v);
                add(i + 1, j + 1, k, d, 0, 0, v);
                add(i + 1, j, k, d, 0, 0, v * (j << 1));
                add(i + 1, j - 1, k, d, 0, 0, v * j * (j - 1));
                
                add(i + 1, j - 1, k, d, 0, 1, v * j);
                add(i + 1, j - 1, k, d, 1, 0, v * j);
                
                //0 1
                v = dp[i][j][k][0][1];
                add(i + 1, j, k, d, 1, 1, v);
                add(i + 1, j, k, d, 0, 1, v);
                add(i + 1, j + 1, k, d, 0, 1, v);
                add(i + 1, j, k, d, 0, 1, v * (j << 1));
                add(i + 1, j - 1, k, d, 0, 1, v * j * (j - 1));
                
                add(i + 1, j - 1, k, d, 0, 1, v * j);
                add(i + 1, j - 1, k, d, 1, 1, v * j);
                
                //1 0
                v = dp[i][j][k][1][0];
                add(i + 1, j, k, d, 1, 0, v);
                add(i + 1, j, k, d, 1, 1, v);
                add(i + 1, j + 1, k, d, 1, 0, v);
                add(i + 1, j, k, d, 1, 0, v * (j << 1));
                add(i + 1, j - 1, k, d, 1, 0, v * j * (j - 1));
                
                add(i + 1, j - 1, k, d, 1, 1, v * j);
                add(i + 1, j - 1, k, d, 1, 0, v * j);
                
                //1 1
                v = dp[i][j][k][1][1];
                add(i + 1, j, k, d, 1, 1, v);
                add(i + 1, j, k, d, 1, 1, v);
                add(i + 1, j + 1, k, d, 1, 1, v);
                add(i + 1, j, k, d, 1, 1, v * (j << 1));
                add(i + 1, j - 1, k, d, 1, 1, v * j * (j - 1));
                
                add(i + 1, j - 1, k, d, 1, 1, v * (j << 1));
            }
        }
    }
    
    int ret = 0;
    for (int i = 0; i <= l; ++i) {
        ret += dp[n - 1][0][i][1][1];
        ret %= mod;
        ret += dp[n - 1][0][i][0][1];
        ret %= mod;
        ret += dp[n - 1][0][i][1][0];
        ret %= mod;
    }
    printf("%d\n", ret);
	return 0;
}

Compilation message

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:35: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:37: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 Incorrect 2 ms 248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 740 KB Output is correct
2 Correct 4 ms 944 KB Output is correct
3 Correct 3 ms 944 KB Output is correct
4 Correct 4 ms 944 KB Output is correct
5 Correct 4 ms 944 KB Output is correct
6 Correct 5 ms 1008 KB Output is correct
7 Correct 4 ms 1008 KB Output is correct
8 Correct 3 ms 1060 KB Output is correct
9 Correct 3 ms 1232 KB Output is correct
10 Correct 3 ms 1232 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 248 KB Output isn't correct
2 Halted 0 ms 0 KB -