제출 #528147

#제출 시각아이디문제언어결과실행 시간메모리
528147buidangnguyen05Skyscraper (JOI16_skyscraper)C++14
100 / 100
104 ms29412 KiB
/* input */ #include<bits/stdc++.h> using namespace std; typedef long long ll; const int N = 110, mod = 1e9 + 7; int a[N], f[N][N][10 * N][3]; void add(int &x, int y) { x += y; if (x >= mod) x -= mod; } signed main() { cin.tie(0)->sync_with_stdio(0); if (fopen("task.inp", "r")) { freopen("task.inp", "r", stdin); freopen("task.out", "w", stdout); } int n, mx; cin >> n >> mx; for (int i = 1; i <= n; ++i) cin >> a[i]; if (n == 1) { cout << "1\n"; exit(0); } sort (a + 1, a + n + 1); a[n + 1] = 1e5; f[0][0][0][0] = 1; for (int i = 1; i <= n; ++i) for (int j = 1; j <= i; ++j) { for (int k = 1; k <= mx; ++k) for (int m = 0; m < 3; ++m) { int diff = (2 * j - m) * (a[i + 1] - a[i]); if (diff > k || i + j + 1 - m > n) continue; add(f[i][j][k][m], f[i - 1][j - 1][k - diff][m]); if (m) add(f[i][j][k][m], 1LL * (3 - m) * f[i - 1][j - 1][k - diff][m - 1] % mod); add(f[i][j][k][m], 1LL * (2 * j - m) * f[i - 1][j][k - diff][m] % mod); if (m == 1) add(f[i][j][k][m], 2LL * j * f[i - 1][j][k - diff][m - 1] % mod); else if (m == 2) { if (i == n) add(f[i][j][k][m], f[i - 1][j][k - diff][m - 1]); else add(f[i][j][k][m], 1LL * (j - 1) * f[i - 1][j][k - diff][m - 1] % mod); } if (m == 1) add(f[i][j][k][m], 1LL * j * j * f[i - 1][j + 1][k - diff][m] % mod); else if (!m) add(f[i][j][k][m], 1LL * j * (j + 1) * f[i - 1][j + 1][k - diff][m] % mod); else { if (i == n) add(f[i][j][k][m], f[i - 1][j + 1][k - diff][m]); else add(f[i][j][k][m], 1LL * j * (j - 1) * f[i - 1][j + 1][k - diff][m] % mod); } } } int res = 0; for (int i = 0; i <= mx; ++i) add(res, f[n][1][i][2]); cout << res << "\n"; }

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

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