제출 #1261778

#제출 시각아이디문제언어결과실행 시간메모리
1261778son2008Skyscraper (JOI16_skyscraper)C++20
15 / 100
1 ms840 KiB
#include <bits/stdc++.h>
using namespace std;
#define ii pair<int, int>
#define fi first
#define se second
// #define int long long
#define ll long long
#define ld double
#define mp make_pair
#define lg2 30
#define iii pair<int, ii>
#define iiii pair<ii, ii>
#define base 29
#define eps 1e-8
#define MASK(i) (1LL << (i))
#define BIT(S, i) (((S) >> (i)) & 1)
int dx[] = {0LL, 0LL, 1, -1, 1, 1, -1, -1};
int dy[] = {1, -1, 0LL, 0LL, 1, -1, 1, -1};
const int maxn = 1e2 + 5;
const int mod = 1e9 + 7;
int f[maxn][maxn][maxn * 10][3], a[maxn], n, L;
void add(int &x, int y)
{
    x = (x + (y % mod)) % mod;
}
signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#define task "task"
    if (fopen(task ".inp", "r"))
    {
        freopen(task ".inp", "r", stdin);
        freopen(task ".out", "w", stdout);
    }
    cin >> n >> L;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    sort(a + 1, a + n + 1);
    f[0][0][0][0] = 1;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j <= i; j++)
        {
            for (int s = 0; s <= L; s++)
            {
                for (int e = 0; e <= 2; e++)
                {
                    int g = s + (2 * j - e) * (a[i + 1] - a[i]), x = f[i][j][s][e];
                    if (g > L)
                        continue;
                    // tao mot tplt moi khong phai bien
                    add(f[i + 1][j + 1][g][e], 1LL * x * (j - 1 + 2 - e));
                    // tao mot tplt moi la bien
                    add(f[i + 1][j + 1][g][e + 1], 1LL * x * (2 - e));
                    // hop hai doan lien tiep
                    if (j >= 2)
                        add(f[i + 1][j - 1][g][e], 1LL * (j - 1) * x);
                    // chen 1 phan tu moi vao dau mut khong phai bien cua mot doan
                    if (j >= 1)
                        add(f[i + 1][j][g][e], 1LL * x * (2 * j - e));
                    // chen 1 phan tu moi va la bien cua mot doan
                    if (j >= 1)
                        add(f[i + 1][j][g][e + 1], 1LL * x * (2 - e));
                }
            }
        }
    }
    int ans = 0;
    for (int j = 0; j <= L; j++)
    {
        add(ans, f[n][1][j][2]);
    }
    cout << ans;
    cerr << endl
         << "TIME : " << clock() * 0.001 << "s" << endl;
}

컴파일 시 표준 에러 (stderr) 메시지

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:34:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |         freopen(task ".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
skyscraper.cpp:35:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |         freopen(task ".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...