Submission #1174733

#TimeUsernameProblemLanguageResultExecution timeMemory
1174733chikien2009Skyscraper (JOI16_skyscraper)C++20
0 / 100
1 ms324 KiB
#include <bits/stdc++.h> using namespace std; void setup() { #ifndef ONLINE_JUDGE freopen("test.inp", "r", stdin); freopen("test.out", "w", stdout); #endif ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } int n, a[101], b, l; long long f[101][101][1001][3], mod = 1e9 + 7; inline void Add(long long &ina, long long inb) { ina = (ina + inb) % mod; } inline long long Mul(long long ina, long long inb) { return (ina * inb) % mod; } int main() { setup(); 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 k = 0; k <= l; ++k) { for (int g = 0; g <= 2; ++g) { f[i][j][k][g] %= mod; b = (a[i + 1] - a[i]) * (2 * j - g) + k; if (b < 0 || b > l || f[i][j][k][g] == 0) { continue; } Add(f[i + 1][j + 1][b][g], Mul(f[i][j][k][g], j + 1 - g)); if (g < 2) { Add(f[i + 1][j + 1][b][g + 1], Mul(f[i][j][k][g], 2 - g)); } if (j > 0) { Add(f[i + 1][j][b][g], Mul(f[i][j][k][g], 2 * j - g)); if (g < 2) { Add(f[i + 1][j][b][g + 1], Mul(f[i][j][k][g], 2 - g)); } } if (1 < j) { Add(f[i + 1][j - 1][b][g], Mul(f[i][j][k][g], j - 1)); } } } } } b = 0; for (int i = 0; i <= l; ++i) { (b += f[n][1][i][2]) % mod; } cout << b; return 0; }

Compilation message (stderr)

skyscraper.cpp: In function 'void setup()':
skyscraper.cpp:8:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     freopen("test.inp", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
skyscraper.cpp:9:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     freopen("test.out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...