Submission #7606714


Source Code Expand

Copy
#include<bits/stdc++.h>
using namespace std;
namespace mine
{
    typedef long long ll;
    #define pr pair<int,int>
    #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 GG(x) if(x) puts("error")
    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> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=1e9+7;
    inline int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> inline void add(T &x,const T y){x=mm(x+y);}
    inline ll qpower(ll x,ll e)
    {
        ll ans=1;GG(e<0);
        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=2e3+10;

    int C[N][N],pp[N][N],solve1[N][N];
    void main()
    {
        C[0][0]=1;for(int i=0;i<N;i++) pp[0][i]=solve1[0][i]=1;
        for(int i=1;i<N;i++)
        {
            C[i][0]=pp[i][0]=solve1[i][0]=1;
            for(int j=1;j<N;j++)
            {
                C[i][j]=mm(C[i-1][j-1]+C[i-1][j]);
                pp[i][j]=mm(pp[i][j-1]+C[i][j]);
            }
        }
        for(int i=1;i<N;i++) for(int j=1;j<N;j++) solve1[i][j]=mm(solve1[i-1][j]+pp[j-1][i]);

        int A=qread(),B=qread();ll ans=0;
        for(int t=1;t<=A+1;t++) for(int i=0;i<=t-1;i++) add(ans, 1ll*C[B-1][i]*solve1[t-1-i][i]%MOD );write(ans);
    }//(ans+MOD)%MOD
};
int main()
{
    srand(time(0));
    mine::main();
}

Submission Info

Submission Time
Task E - Popping Balls
User Zory
Language C++14 (GCC 5.4.1)
Score 1600
Code Size 2172 Byte
Status
Exec Time 46 ms
Memory 47744 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 example0.txt, example1.txt, example2.txt, example3.txt
All 1600 / 1600 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 031.txt, 032.txt, 033.txt, 034.txt, 035.txt, 036.txt, 037.txt, 038.txt, 039.txt, 040.txt, 041.txt, 042.txt, 043.txt, example0.txt, example1.txt, example2.txt, example3.txt
Case Name Status Exec Time Memory
000.txt 45 ms 47616 KB
001.txt 31 ms 47616 KB
002.txt 45 ms 47616 KB
003.txt 31 ms 47616 KB
004.txt 45 ms 47744 KB
005.txt 45 ms 47616 KB
006.txt 45 ms 47616 KB
007.txt 44 ms 47616 KB
008.txt 44 ms 47616 KB
009.txt 44 ms 47616 KB
010.txt 44 ms 47616 KB
011.txt 45 ms 47616 KB
012.txt 44 ms 47616 KB
013.txt 44 ms 47616 KB
014.txt 34 ms 47616 KB
015.txt 37 ms 47616 KB
016.txt 32 ms 47616 KB
017.txt 32 ms 47616 KB
018.txt 31 ms 47616 KB
019.txt 31 ms 47616 KB
020.txt 39 ms 47616 KB
021.txt 31 ms 47616 KB
022.txt 35 ms 47616 KB
023.txt 32 ms 47616 KB
024.txt 37 ms 47616 KB
025.txt 31 ms 47616 KB
026.txt 38 ms 47616 KB
027.txt 35 ms 47616 KB
028.txt 40 ms 47616 KB
029.txt 31 ms 47616 KB
030.txt 33 ms 47616 KB
031.txt 32 ms 47616 KB
032.txt 31 ms 47616 KB
033.txt 45 ms 47616 KB
034.txt 31 ms 47616 KB
035.txt 31 ms 47616 KB
036.txt 31 ms 47616 KB
037.txt 31 ms 47616 KB
038.txt 31 ms 47616 KB
039.txt 31 ms 47616 KB
040.txt 31 ms 47616 KB
041.txt 31 ms 47616 KB
042.txt 31 ms 47616 KB
043.txt 31 ms 47616 KB
example0.txt 31 ms 47616 KB
example1.txt 31 ms 47616 KB
example2.txt 31 ms 47616 KB
example3.txt 46 ms 47616 KB