Submission #643277

#TimeUsernameProblemLanguageResultExecution timeMemory
643277valerikkTents (JOI18_tents)C++17
100 / 100
116 ms70720 KiB
#include <cstdio> #define MOD 1000000007 #define MAX 3003 long long dp[MAX][MAX]; int main() { int H, W; scanf("%d%d", &H, &W); dp[0][0] = 1; for (int w = 1; w <= W; ++w) { dp[0][w] = 1; } for (int h = 1; h <= H; ++h) { dp[h][0] = 1; } for (int h = 1; h <= H; ++h) { for (int w = 1; w <= W; ++w) { dp[h][w] = (dp[h][w] + dp[h - 1][w]) % MOD; if (w >= 2) dp[h][w] = (dp[h][w] + w * 1LL * (w - 1) / 2 % MOD * dp[h - 1][w - 2]) % MOD; dp[h][w] = (dp[h][w] + w * 4 * dp[h - 1][w - 1]) % MOD; if (h >= 2) dp[h][w] = (dp[h][w] + w * 1LL * (h - 1) * dp[h - 2][w - 1]) % MOD; } } printf("%lld\n", (dp[H][W] - 1 + MOD) % MOD); }

Compilation message (stderr)

tents.cpp: In function 'int main()':
tents.cpp:11:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |   scanf("%d%d", &H, &W);
      |   ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...