Submission #9467673


Source Code Expand

Copy
//Zory-2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define Debug printf("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define debug(x) cerr<<#x<<'='<<x<<endl
#define mem(x,val) memset(x,val,sizeof x)
namespace mine
{
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
    template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
    bool IN(ll x,ll l,ll r){return l<=x and x<=r;}

    const int INF=0x3f3f3f3f;
    const int MOD=1e9+7;
    int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
    ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e3+10;

    int C[N][N],f[100][N];
    void main()
	{
        C[0][0]=1;fo(i,1,N-1){C[i][0]=1;fo(j,1,i)C[i][j]=mm(C[i-1][j-1]+C[i-1][j]);}
        int n=qread(),k=qread();f[0][n]=1;
        fo(id,1,k)
        {
            int a=qread();
            fo(i,0,n) fo(t,0,i)
                add(f[id][i-t],1ll*f[id-1][i]* C[i][t]%MOD*C[n-t][n-a]%MOD );
        }
        write(f[k][0]);
	}
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}

Submission Info

Submission Time
Task C - Cookie Distribution
User Zory
Language C++14 (GCC 5.4.1)
Score 800
Code Size 2153 Byte
Status
Exec Time 66 ms
Memory 4352 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 800 / 800
Status
× 2
× 32
Set Name Test Cases
Sample sample_01, sample_02
All max_01, max_02, max_03, max_04, max_05, max_06, max_07, max_08, max_09, max_10, random_01, random_02, random_03, random_04, random_05, random_06, random_07, random_08, random_09, random_10, random_small_01, random_small_02, random_small_03, random_small_04, random_small_05, random_small_06, random_small_07, random_small_08, random_small_09, random_small_10, sample_01, sample_02
Case Name Status Exec Time Memory
max_01 64 ms 4352 KB
max_02 66 ms 4352 KB
max_03 65 ms 4352 KB
max_04 66 ms 4352 KB
max_05 64 ms 4352 KB
max_06 66 ms 4352 KB
max_07 65 ms 4352 KB
max_08 66 ms 4352 KB
max_09 64 ms 4352 KB
max_10 66 ms 4352 KB
random_01 9 ms 4224 KB
random_02 4 ms 4224 KB
random_03 21 ms 4224 KB
random_04 18 ms 4224 KB
random_05 5 ms 4224 KB
random_06 9 ms 4224 KB
random_07 35 ms 4352 KB
random_08 8 ms 4224 KB
random_09 29 ms 4352 KB
random_10 10 ms 4352 KB
random_small_01 3 ms 4224 KB
random_small_02 3 ms 4224 KB
random_small_03 3 ms 4224 KB
random_small_04 3 ms 4224 KB
random_small_05 3 ms 4224 KB
random_small_06 3 ms 4224 KB
random_small_07 3 ms 4224 KB
random_small_08 3 ms 4224 KB
random_small_09 3 ms 4224 KB
random_small_10 3 ms 4224 KB
sample_01 3 ms 4224 KB
sample_02 39 ms 4352 KB