답안 #205990

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
205990 2020-03-01T19:01:53 Z stefdasca Skyscraper (JOI16_skyscraper) C++14
컴파일 오류
0 ms 0 KB
/*
        JOIOC 16-skyscraper


*/
#include<bits/stdc++.h>
#define god dimasi5eks
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mod 1000000007
#define dancila 3.14159265359
#define eps 1e-9

// #define fisier 1

using namespace std;

typedef long long ll;


int add(int a, int b)
{
    int x = a+b;
    if(x >= mod)
        x -= mod;
    if(x < 0)
        x += mod;
    return x;
}
ll mul(ll a, ll b)
{
    return (a*b) % mod;
}

int n, maxsum;
ll v[102];

ll dp[102][102][1002][3];
/*
    dp[i][j][k][l]:
    i - number of numbers placed
    j - number of connected components
    k - total sum currently (filling empty spaces with a_{i} (0-indexed)
    l - number of endpoints that are filled
*/

int solve(int i, int j, int k, int l)
{
    if(i > 0 && (j < 1 || l > 2 || k > maxsum)) // invalid conditions
        return 0;
    if(i == n)
        return (j == 1 && l == 2);
    if(dp[i][j][k][l] != -1)
        return dp[i][j][k][l];
    int s = (a[i + 1] - a[i]) * (2 * j - l) + k;
    dp[i][j][k][l] = 0;
    add(dp[i][j][k][l], mul((j + 1 - l), solve(i + 1, j + 1, s, l)));
    add(dp[i][j][k][l], mul((2 - l), solve(i + 1, j, s, l + 1)));
    add(dp[i][j][k][l], mul((2 - l), solve(i + 1, j + 1, s, l + 1)));
    add(dp[i][j][k][l], mul((j - 1), solve(i + 1, j - 1, s, l)));
    add(dp[i][j][k][l], mul((2 * j - l), solve(i + 1, j, s, l)));
    return dp[i][j][k][l];
}

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> maxsum;
    for(int i = 1; i <= n; i++)
        cin >> v[i];
    sort(v + 1, v + n + 1);
    if(n == 1)
    {
        cout << 1;
        return 0;
    }
    memset(dp, -1, sizeof(dp));
    v[0] = v[1];
    cout << solve(0, 0, 0, 0);
    return 0;
}

Compilation message

skyscraper.cpp: In function 'int solve(int, int, int, int)':
skyscraper.cpp:58:14: error: 'a' was not declared in this scope
     int s = (a[i + 1] - a[i]) * (2 * j - l) + k;
              ^