Submission #3420209


Source Code Expand

#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int n, d, a[33], dp[33][33][1010], pa[1010][1010], dcomb[1010], res;

int comb(int n, int r) {
	if (r<0 || r>n) return 0;
	if (r==0) return 1;
	if (pa[n][r]) return pa[n][r];
	return pa[n][r] = (comb(n-1, r-1) + comb(n-1, r)) %mod;
}

void dcinit() {
	dcomb[0] = 1;
	int num = 1, den = 1;
	reps(i,1,1010) {
		(num *= d-i+1) %= mod;
		(den *= i) %= mod;
		dcomb[i] = num * mop(den,mod-2) %mod;
	}
}

signed main() {
	cin >> n >> d;
	rep(i,n) cin >> a[i];
	dp[0][0][0] = 1;
	rep(i,n) rep(j,n) rep(k,1010) if (dp[i][j][k]) {
		(dp[i+1][j][k] += dp[i][j][k]) %= mod;
		rep(l,a[i]) (dp[i+1][j+1][k+l] += dp[i][j][k] * comb(k+l,l)) %= mod;
	}
	dcinit();
	rep(i,n+1) rep(j,min(1010ll,d+1))
		(res += dp[n][i][j] * dcomb[j] %mod * mop(n-i,d-j) * (i%2 ? -1 : 1)) %= mod;
	cout << res << endl;
}

Submission Info

Submission Time
Task D - 天下一ボディービルコンテスト
User creep04
Language C++14 (GCC 5.4.1)
Score 0
Code Size 3054 Byte
Status WA
Exec Time 29 ms
Memory 15744 KB

Judge Result

Set Name level1 level2 level3
Score / Max Score 0 / 40 0 / 100 0 / 140
Status
AC × 24
WA × 3
AC × 44
WA × 6
AC × 55
WA × 19
Set Name Test Cases
level1 level1_max_0.txt, level1_maxrand_0.txt, level1_maxrand_1.txt, level1_maxrand_2.txt, level1_maxrand_3.txt, level1_maxrand_4.txt, level1_maxrand_5.txt, level1_maxrand_6.txt, level1_maxrand_7.txt, level1_maxrand_8.txt, level1_maxrand_9.txt, level1_min1_0.txt, level1_min2_0.txt, level1_min3_0.txt, level1_min4_0.txt, level1_rand_0.txt, level1_rand_1.txt, level1_rand_2.txt, level1_rand_3.txt, level1_rand_4.txt, level1_rand_5.txt, level1_rand_6.txt, level1_rand_7.txt, level1_rand_8.txt, level1_rand_9.txt, level1_sample1.txt, level1_sample2.txt
level2 level1_max_0.txt, level1_maxrand_0.txt, level1_maxrand_1.txt, level1_maxrand_2.txt, level1_maxrand_3.txt, level1_maxrand_4.txt, level1_maxrand_5.txt, level1_maxrand_6.txt, level1_maxrand_7.txt, level1_maxrand_8.txt, level1_maxrand_9.txt, level1_min1_0.txt, level1_min2_0.txt, level1_min3_0.txt, level1_min4_0.txt, level1_rand_0.txt, level1_rand_1.txt, level1_rand_2.txt, level1_rand_3.txt, level1_rand_4.txt, level1_rand_5.txt, level1_rand_6.txt, level1_rand_7.txt, level1_rand_8.txt, level1_rand_9.txt, level1_sample1.txt, level1_sample2.txt, level2_max_0.txt, level2_maxrand_0.txt, level2_maxrand_1.txt, level2_maxrand_2.txt, level2_maxrand_3.txt, level2_maxrand_4.txt, level2_maxrand_5.txt, level2_maxrand_6.txt, level2_maxrand_7.txt, level2_maxrand_8.txt, level2_maxrand_9.txt, level2_min1_0.txt, level2_min2_0.txt, level2_rand_0.txt, level2_rand_1.txt, level2_rand_2.txt, level2_rand_3.txt, level2_rand_4.txt, level2_rand_5.txt, level2_rand_6.txt, level2_rand_7.txt, level2_rand_8.txt, level2_rand_9.txt
level3 level1_max_0.txt, level1_maxrand_0.txt, level1_maxrand_1.txt, level1_maxrand_2.txt, level1_maxrand_3.txt, level1_maxrand_4.txt, level1_maxrand_5.txt, level1_maxrand_6.txt, level1_maxrand_7.txt, level1_maxrand_8.txt, level1_maxrand_9.txt, level1_min1_0.txt, level1_min2_0.txt, level1_min3_0.txt, level1_min4_0.txt, level1_rand_0.txt, level1_rand_1.txt, level1_rand_2.txt, level1_rand_3.txt, level1_rand_4.txt, level1_rand_5.txt, level1_rand_6.txt, level1_rand_7.txt, level1_rand_8.txt, level1_rand_9.txt, level1_sample1.txt, level1_sample2.txt, level2_max_0.txt, level2_maxrand_0.txt, level2_maxrand_1.txt, level2_maxrand_2.txt, level2_maxrand_3.txt, level2_maxrand_4.txt, level2_maxrand_5.txt, level2_maxrand_6.txt, level2_maxrand_7.txt, level2_maxrand_8.txt, level2_maxrand_9.txt, level2_min1_0.txt, level2_min2_0.txt, level2_rand_0.txt, level2_rand_1.txt, level2_rand_2.txt, level2_rand_3.txt, level2_rand_4.txt, level2_rand_5.txt, level2_rand_6.txt, level2_rand_7.txt, level2_rand_8.txt, level2_rand_9.txt, level3_max_0.txt, level3_maxrand_0.txt, level3_maxrand_1.txt, level3_maxrand_2.txt, level3_maxrand_3.txt, level3_maxrand_4.txt, level3_maxrand_5.txt, level3_maxrand_6.txt, level3_maxrand_7.txt, level3_maxrand_8.txt, level3_maxrand_9.txt, level3_min1_0.txt, level3_min2_0.txt, level3_rand_0.txt, level3_rand_1.txt, level3_rand_2.txt, level3_rand_3.txt, level3_rand_4.txt, level3_rand_5.txt, level3_rand_6.txt, level3_rand_7.txt, level3_rand_8.txt, level3_rand_9.txt, level3_sample3.txt
Case Name Status Exec Time Memory
level1_max_0.txt AC 2 ms 4480 KB
level1_maxrand_0.txt AC 2 ms 4480 KB
level1_maxrand_1.txt WA 2 ms 4352 KB
level1_maxrand_2.txt AC 2 ms 4480 KB
level1_maxrand_3.txt AC 2 ms 4352 KB
level1_maxrand_4.txt AC 2 ms 4352 KB
level1_maxrand_5.txt AC 2 ms 4352 KB
level1_maxrand_6.txt AC 2 ms 4480 KB
level1_maxrand_7.txt AC 2 ms 4480 KB
level1_maxrand_8.txt AC 2 ms 4352 KB
level1_maxrand_9.txt AC 2 ms 4352 KB
level1_min1_0.txt AC 2 ms 4352 KB
level1_min2_0.txt WA 2 ms 4352 KB
level1_min3_0.txt AC 2 ms 4480 KB
level1_min4_0.txt AC 2 ms 4352 KB
level1_rand_0.txt AC 2 ms 4352 KB
level1_rand_1.txt AC 2 ms 4352 KB
level1_rand_2.txt AC 2 ms 4352 KB
level1_rand_3.txt AC 2 ms 4352 KB
level1_rand_4.txt AC 2 ms 4480 KB
level1_rand_5.txt WA 2 ms 4352 KB
level1_rand_6.txt AC 2 ms 4352 KB
level1_rand_7.txt AC 2 ms 4352 KB
level1_rand_8.txt AC 2 ms 4352 KB
level1_rand_9.txt AC 2 ms 4352 KB
level1_sample1.txt AC 2 ms 4352 KB
level1_sample2.txt AC 2 ms 4352 KB
level2_max_0.txt AC 3 ms 4480 KB
level2_maxrand_0.txt AC 3 ms 4352 KB
level2_maxrand_1.txt AC 3 ms 4480 KB
level2_maxrand_2.txt AC 3 ms 4352 KB
level2_maxrand_3.txt AC 3 ms 4480 KB
level2_maxrand_4.txt AC 3 ms 4480 KB
level2_maxrand_5.txt AC 3 ms 4352 KB
level2_maxrand_6.txt AC 3 ms 4352 KB
level2_maxrand_7.txt AC 3 ms 4480 KB
level2_maxrand_8.txt AC 3 ms 4352 KB
level2_maxrand_9.txt AC 3 ms 4480 KB
level2_min1_0.txt WA 3 ms 4352 KB
level2_min2_0.txt AC 2 ms 4352 KB
level2_rand_0.txt AC 3 ms 4352 KB
level2_rand_1.txt AC 2 ms 4352 KB
level2_rand_2.txt AC 2 ms 4352 KB
level2_rand_3.txt AC 2 ms 4352 KB
level2_rand_4.txt AC 3 ms 4480 KB
level2_rand_5.txt WA 3 ms 4352 KB
level2_rand_6.txt AC 3 ms 4352 KB
level2_rand_7.txt AC 2 ms 4352 KB
level2_rand_8.txt WA 2 ms 4352 KB
level2_rand_9.txt AC 2 ms 4352 KB
level3_max_0.txt WA 29 ms 15744 KB
level3_maxrand_0.txt WA 17 ms 13696 KB
level3_maxrand_1.txt WA 15 ms 13696 KB
level3_maxrand_2.txt WA 14 ms 13696 KB
level3_maxrand_3.txt WA 15 ms 13696 KB
level3_maxrand_4.txt WA 15 ms 13696 KB
level3_maxrand_5.txt WA 17 ms 13696 KB
level3_maxrand_6.txt WA 16 ms 13696 KB
level3_maxrand_7.txt WA 15 ms 13568 KB
level3_maxrand_8.txt WA 16 ms 13696 KB
level3_maxrand_9.txt WA 15 ms 13696 KB
level3_min1_0.txt AC 9 ms 10496 KB
level3_min2_0.txt AC 2 ms 4480 KB
level3_rand_0.txt AC 10 ms 11648 KB
level3_rand_1.txt AC 10 ms 11648 KB
level3_rand_2.txt WA 3 ms 4480 KB
level3_rand_3.txt AC 6 ms 7168 KB
level3_rand_4.txt AC 3 ms 4608 KB
level3_rand_5.txt AC 6 ms 7296 KB
level3_rand_6.txt AC 5 ms 7168 KB
level3_rand_7.txt AC 8 ms 9472 KB
level3_rand_8.txt AC 4 ms 6912 KB
level3_rand_9.txt WA 3 ms 4736 KB
level3_sample3.txt AC 4 ms 6784 KB