답안 #282677

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
282677 2020-08-24T17:52:15 Z mat_v Tents (JOI18_tents) C++14
100 / 100
539 ms 67704 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
#define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
#define mod 1000000007
#define xx first
#define yy second
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ll long long
#define pii pair<int,int>


using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;/// find_by_order(x)(x+1th) , order_of_key() (strictly less)
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());


ll mul(ll x, ll y){return (x*y)%mod;}
ll add(ll x, ll y){return (x+y)%mod;}

bool bio[3005][3005];
ll dp[3005][3005];

ll resi(ll x, ll y){
    if(x == 0 || y == 0)return 1;
    if(bio[x][y])return dp[x][y];
    bio[x][y] = 1;
    ll tmp = 0;
    tmp = add(resi(x - 1, y), tmp);
    tmp = add(mul(resi(x - 1,y - 1), 4*y), tmp);

    ll bruh = (y * (y - 1)) / 2;
    bruh %= mod;
    ll tmp1 = 0;
    if(x && y >= 2)tmp1 = mul(resi(x - 1, y - 2), bruh);

    bruh = mul(x - 1 , y);
    ll tmp2 = 0;
    if(x >= 2 && y)tmp2 = mul(resi(x - 2, y - 1), bruh);

    tmp = add(tmp, tmp1);
    tmp = add(tmp, tmp2);
    return dp[x][y] = tmp;
}



int main()
{

    ios_base::sync_with_stdio(false); cin.tie(0);
    int n,m;
    cin >> n >> m;
    cout << (resi(n,m) - 1 + mod)%mod << "\n";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 640 KB Output is correct
4 Correct 4 ms 1792 KB Output is correct
5 Correct 1 ms 768 KB Output is correct
6 Correct 2 ms 2048 KB Output is correct
7 Correct 1 ms 1024 KB Output is correct
8 Correct 2 ms 2176 KB Output is correct
9 Correct 1 ms 1152 KB Output is correct
10 Correct 3 ms 2688 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 4 ms 2944 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 640 KB Output is correct
4 Correct 4 ms 1792 KB Output is correct
5 Correct 1 ms 768 KB Output is correct
6 Correct 2 ms 2048 KB Output is correct
7 Correct 1 ms 1024 KB Output is correct
8 Correct 2 ms 2176 KB Output is correct
9 Correct 1 ms 1152 KB Output is correct
10 Correct 3 ms 2688 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 4 ms 2944 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 10 ms 16640 KB Output is correct
15 Correct 330 ms 55476 KB Output is correct
16 Correct 4 ms 2432 KB Output is correct
17 Correct 27 ms 8952 KB Output is correct
18 Correct 64 ms 17016 KB Output is correct
19 Correct 384 ms 61944 KB Output is correct
20 Correct 299 ms 49400 KB Output is correct
21 Correct 167 ms 30328 KB Output is correct
22 Correct 190 ms 37240 KB Output is correct
23 Correct 103 ms 35320 KB Output is correct
24 Correct 539 ms 67704 KB Output is correct
25 Correct 389 ms 56952 KB Output is correct
26 Correct 449 ms 62968 KB Output is correct
27 Correct 505 ms 65596 KB Output is correct