Submission #392940

# Submission time Handle Problem Language Result Execution time Memory
392940 2021-04-22T10:54:17 Z cpp219 Tents (JOI18_tents) C++14
100 / 100
421 ms 71376 KB
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fs first
#define sc second
using namespace std;
typedef pair<ll,ll> LL;
const ll N = 3e3 + 9;
const ll mod = 1e9 + 7;
ll x,y;
ll dp[N][N];

ll f(ll n,ll m){
    if (n*m == 0) return m < y;
    if (dp[n][m] != -1) return dp[n][m];
    ll ans = 0;
    if (m >= 2) ans = (ans + f(n - 1,m - 2)*m*(m - 1)/2)%mod;
    ans = (ans + 4*m*f(n - 1,m - 1) + f(n - 1,m))%mod;
    if (n >= 2) ans = (ans + f(n - 2,m - 1)*m*(n - 1))%mod;
    return dp[n][m] = ans;
}


int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #define task "tst"
    if (fopen(task".inp","r")){
        freopen(task".inp","r",stdin);
        //freopen(task".out","w",stdout);
    }
    cin>>x>>y; memset(dp,-1,sizeof(dp));
    cout<<f(x,y);
}

Compilation message

tents.cpp: In function 'int main()':
tents.cpp:28:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   28 |         freopen(task".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 31 ms 71256 KB Output is correct
2 Correct 31 ms 71184 KB Output is correct
3 Correct 30 ms 71116 KB Output is correct
4 Correct 30 ms 71104 KB Output is correct
5 Correct 30 ms 71100 KB Output is correct
6 Correct 31 ms 71108 KB Output is correct
7 Correct 31 ms 71080 KB Output is correct
8 Correct 31 ms 71096 KB Output is correct
9 Correct 37 ms 71152 KB Output is correct
10 Correct 32 ms 71120 KB Output is correct
11 Correct 30 ms 71088 KB Output is correct
12 Correct 33 ms 71176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 71256 KB Output is correct
2 Correct 31 ms 71184 KB Output is correct
3 Correct 30 ms 71116 KB Output is correct
4 Correct 30 ms 71104 KB Output is correct
5 Correct 30 ms 71100 KB Output is correct
6 Correct 31 ms 71108 KB Output is correct
7 Correct 31 ms 71080 KB Output is correct
8 Correct 31 ms 71096 KB Output is correct
9 Correct 37 ms 71152 KB Output is correct
10 Correct 32 ms 71120 KB Output is correct
11 Correct 30 ms 71088 KB Output is correct
12 Correct 33 ms 71176 KB Output is correct
13 Correct 30 ms 71144 KB Output is correct
14 Correct 30 ms 71224 KB Output is correct
15 Correct 322 ms 71344 KB Output is correct
16 Correct 32 ms 71064 KB Output is correct
17 Correct 52 ms 71116 KB Output is correct
18 Correct 70 ms 71244 KB Output is correct
19 Correct 337 ms 71372 KB Output is correct
20 Correct 254 ms 71320 KB Output is correct
21 Correct 135 ms 71368 KB Output is correct
22 Correct 185 ms 71304 KB Output is correct
23 Correct 142 ms 71372 KB Output is correct
24 Correct 421 ms 71364 KB Output is correct
25 Correct 307 ms 71332 KB Output is correct
26 Correct 379 ms 71376 KB Output is correct
27 Correct 416 ms 71372 KB Output is correct