Submission #370924

#TimeUsernameProblemLanguageResultExecution timeMemory
370924mjhmjh1104Tents (JOI18_tents)C++14
100 / 100
503 ms36076 KiB
#include <cstdio> #include <algorithm> using namespace std; const int MOD = 1e9 + 7; int dp[3006][3006]; int f(int x, int y) { if (dp[x][y] + 1) return dp[x][y]; if (!x || !y) return dp[x][y] = 1; if (x == 1) return dp[x][y] = (1 + 4LL * y % MOD + 1LL * y * (y - 1) / 2 % MOD) % MOD; if (y == 1) return dp[x][y] = (1 + 4LL * x % MOD + 1LL * x * (x - 1) / 2 % MOD) % MOD; return dp[x][y] = (f(x, y - 1) + 4LL * x % MOD * f(x - 1, y - 1) + 1LL * x * (y - 1) % MOD * f(x - 1, y - 2) % MOD + 1LL * x * (x - 1) / 2 % MOD * f(x - 2, y - 1) % MOD) % MOD; } int h, w; int main() { fill(dp[0], dp[3005] + 3006, -1); scanf("%d%d", &h, &w); printf("%d", (f(h, w) + MOD - 1) % MOD); }

Compilation message (stderr)

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