Submission #838707


Source Code Expand

Copy
#include <bits/stdc++.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using namespace std;

using ll=long long;

const ll inf =1LL << 62;
const ll mod=1000000007LL;

inline ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
inline ll ADD(const ll &a, const ll &b,const ll &mod) { return a+b<mod?a+b:a+b-mod;}
inline ll SUB(const ll &a, const ll &b,const ll &mod) { return a-b>=0?a-b:a-b+mod;}
inline ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
inline ll INV(ll a,ll mod){ll x,y;extgcd(a,mod,x,y);return (x%mod+mod)%mod;}
inline ll DIV(const ll &a, const ll &b,const ll &mod) {return MUL(a,INV(b,mod),mod);}
inline ll POW(ll a,ll n,ll mod){ll b=1LL;for(a%=mod;n;a=MUL(a,a,mod),n>>=1)if(n&1) b=MUL(b,a,mod); return b;}

ll a[410],b[410];
ll coef[410][410];
int n,c;

ll rec(ll i,ll res){
	if(i==n) return res==0;

	ll &ret=coef[i][res];
	if(ret!=-1) return ret;

	ret=0LL;
	ll cur=1LL;
	rrep(nxt,res+1){
		ll tar=MUL(cur,rec(i+1,nxt),mod);
		ret=ADD(ret,tar,mod);
		cur=MUL(cur,a[i],mod);
	}
	return ret;
}

int main(void){
	cin >> n >> c;
	rep(i,n) cin >> a[i];
	rep(i,n) cin >> b[i];

	rep(i,n)rep(j,c+1) coef[i][j]=-1;
	cout << rec(0,c) << endl;
	return 0;
}

Submission Info

Submission Time
Task E - Children and Candies
User Hec
Language C++14 (GCC 5.4.1)
Score 400
Code Size 2045 Byte
Status WA
Exec Time 375 ms
Memory 1536 KB

Judge Result

Set Name Sample Subtask All
Score / Max Score 0 / 0 400 / 400 0 / 400
Status
AC × 2
WA × 3
AC × 12
AC × 14
WA × 16
Set Name Test Cases
Sample 0_000.txt, 0_001.txt, 0_002.txt, 0_003.txt, 0_004.txt
Subtask 0_001, 0_003, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt
All 0_000.txt, 0_001.txt, 0_002.txt, 0_003.txt, 0_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 2_017.txt, 2_018.txt, 2_019.txt, 2_020.txt, 2_021.txt, 2_022.txt, 2_023.txt, 2_024.txt, 2_025.txt, 2_026.txt, 2_027.txt, 2_028.txt, 2_029.txt
Case Name Status Exec Time Memory
0_000.txt WA 4 ms 256 KB
0_001.txt AC 4 ms 256 KB
0_002.txt WA 4 ms 256 KB
0_003.txt AC 4 ms 256 KB
0_004.txt WA 4 ms 256 KB
1_005.txt AC 4 ms 256 KB
1_006.txt AC 4 ms 256 KB
1_007.txt AC 4 ms 256 KB
1_008.txt AC 7 ms 256 KB
1_009.txt AC 4 ms 256 KB
1_010.txt AC 4 ms 256 KB
1_011.txt AC 6 ms 1536 KB
1_012.txt AC 6 ms 1536 KB
1_013.txt AC 6 ms 1536 KB
1_014.txt AC 374 ms 1536 KB
1_015.txt AC 374 ms 1536 KB
1_016.txt AC 374 ms 1536 KB
2_017.txt WA 4 ms 256 KB
2_018.txt WA 4 ms 256 KB
2_019.txt WA 4 ms 256 KB
2_020.txt WA 4 ms 256 KB
2_021.txt WA 6 ms 1536 KB
2_022.txt WA 6 ms 1536 KB
2_023.txt WA 375 ms 1536 KB
2_024.txt WA 375 ms 1536 KB
2_025.txt WA 64 ms 1536 KB
2_026.txt WA 6 ms 1280 KB
2_027.txt WA 296 ms 1408 KB
2_028.txt WA 9 ms 640 KB
2_029.txt WA 5 ms 384 KB