Submission #729007

# Submission time Handle Problem Language Result Execution time Memory
729007 2023-04-23T11:48:22 Z nguyentunglam Tents (JOI18_tents) C++17
100 / 100
147 ms 35636 KB
#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

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 time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 1108 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 1236 KB Output is correct
7 Correct 1 ms 724 KB Output is correct
8 Correct 2 ms 1364 KB Output is correct
9 Correct 1 ms 724 KB Output is correct
10 Correct 2 ms 1620 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 3 ms 1876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 1108 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 1236 KB Output is correct
7 Correct 1 ms 724 KB Output is correct
8 Correct 2 ms 1364 KB Output is correct
9 Correct 1 ms 724 KB Output is correct
10 Correct 2 ms 1620 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 3 ms 1876 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 5 ms 9564 KB Output is correct
15 Correct 90 ms 32916 KB Output is correct
16 Correct 7 ms 2636 KB Output is correct
17 Correct 21 ms 7892 KB Output is correct
18 Correct 28 ms 10948 KB Output is correct
19 Correct 106 ms 34536 KB Output is correct
20 Correct 85 ms 29064 KB Output is correct
21 Correct 59 ms 19932 KB Output is correct
22 Correct 70 ms 22184 KB Output is correct
23 Correct 45 ms 19676 KB Output is correct
24 Correct 145 ms 35636 KB Output is correct
25 Correct 104 ms 30772 KB Output is correct
26 Correct 126 ms 33460 KB Output is correct
27 Correct 147 ms 34664 KB Output is correct