Submission #952910

#TimeUsernameProblemLanguageResultExecution timeMemory
952910bananadeTents (JOI18_tents)C++17
100 / 100
266 ms70796 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int dp[3005][3005]; int h, w; int mod = 1000000007; int pang(int a) { int jum = 1; int now = 1e9 + 6; vector<int> v; while(now > 0) { if(now % 2 == 1) { v.push_back(1); now--; } else { v.push_back(2); now /= 2; } } } signed main() { ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); cin >> h >> w; for(int i = 0; i <= h; i++) { for(int j = 0; j <= w; j++) { if(i == 0 || j == 0) { dp[i][j] = 1; } else { dp[i][j] = dp[i - 1][j] + (dp[i - 1][j - 1] * j * 4); dp[i][j] %= mod; if(i >= 2) { int a = dp[i - 2][j - 1] * (i - 1) * j; a %= mod; dp[i][j] += a; dp[i][j] %= mod; } if(j >= 2) { int a = dp[i - 1][j - 2] * (j - 1) * j / 2; a %= mod; dp[i][j] += a; dp[i][j] %= mod; } } //cout << i << " " << j << " " << dp[i][j] << "\n"; } } cout << dp[h][w] - 1; }

Compilation message (stderr)

tents.cpp: In function 'long long int pang(long long int)':
tents.cpp:9:6: warning: unused variable 'jum' [-Wunused-variable]
    9 |  int jum = 1;
      |      ^~~
tents.cpp:21:1: warning: no return statement in function returning non-void [-Wreturn-type]
   21 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...