Submission #729007

#TimeUsernameProblemLanguageResultExecution timeMemory
729007nguyentunglamTents (JOI18_tents)C++17
100 / 100
147 ms35636 KiB
#include<bits/stdc++.h> #define fi first #define se second #define endl "\n" #define ii pair<int, int> //#define int long long using namespace std; const int mod = 1e9 + 7, N = 3000; int f[N + 10][N + 10], C[N + 10][N + 10], g[N + 10]; void add(int &a, int b) { a += b; if (a >= mod) a -= mod; } main() { #define task "" cin.tie(0) -> sync_with_stdio(0); if (fopen ("task.inp", "r")) { freopen ("task.inp", "r", stdin); freopen ("task.out", "w", stdout); } if (fopen (task".inp", "r")) { freopen (task".inp", "r", stdin); freopen (task".out", "w", stdout); } int h, w; cin >> h >> w; for(int i = 0; i <= w; i++) f[0][i] = 1; for(int i = 0; i < h; i++) for(int j = 0; j <= w; j++) { add(f[i + 1][j], f[i][j]); add(f[i + 1][j + 1], 1LL * f[i][j] * (j + 1) % mod * 4 % mod); add(f[i + 2][j + 1], 1LL * f[i][j] * (i + 1) % mod * (j + 1) % mod); add(f[i + 1][j + 2], 1LL * f[i][j] * (1LL * (j + 2) * (j + 1) / 2 % mod) % mod); } cout << (f[h][w] - 1 + mod) % mod; }

Compilation message (stderr)

tents.cpp:15:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   15 | main() {
      | ^~~~
tents.cpp: In function 'int main()':
tents.cpp:19:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         freopen ("task.inp", "r", stdin);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
tents.cpp:20:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |         freopen ("task.out", "w", stdout);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
tents.cpp:23:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         freopen (task".inp", "r", stdin);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
tents.cpp:24:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |         freopen (task".out", "w", stdout);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...