# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
956476 |
2024-04-02T05:19:51 Z |
modwwe |
Magneti (COCI21_magneti) |
C++17 |
|
132 ms |
144796 KB |
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2")
#include<bits/stdc++.h>
#define int long long
#define ll long long
#define down cout<<'\n';
#define NHP ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
#define modwwe int t;cin>>t; while(t--)
#define bit(i,j) (i>>j&1)
#define sobit(a) __builtin_popcountll(a)
#define task "test"
#define fin(x) freopen(x".inp","r",stdin)
#define fou(x) freopen(x".out","w",stdout)
#define pb push_back
#define checktime cerr << (double)clock() / CLOCKS_PER_SEC * 1000 << " ms";
using namespace std;
void phongbeo();
const int mod2=1e9+7;
const int mod1=998244353;
struct ib
{
int a;
int b;
};
struct icd
{
int a,b;
};
struct ic
{
int a,b,c;
};
struct id
{
int a,b,c,d;
};
int n,m,s2,s4,s3,sf,k,r,mid,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,l;
int i,s10,s12;
int el=29;
main()
{
//#ifndef ONLINE_JUDGE
// fin(task),fou(task);
//#endif
NHP
//modwwe
// cin>>res;
phongbeo(),down
checktime
}
int dp[51][51][10001], a[51],c[10055][55];
ll C(int n, int k){
if(n == k || k == 0) return 1;
if(k > n) return 0;
if(c[n][k] != -1) return c[n][k];
return c[n][k] = (C(n - 1, k) + C(n - 1, k - 1)) % mod2;
}
void phongbeo()
{
cin>>n>>k;
for(int i=1;i<=n;i++)
cin>>a[i];
sort(a+1,a+1+n);
dp[1][1][1]=1;
memset(c, -1, sizeof c);
for(int i=2;i<=n;i++)
for(int j=1;j<=i;j++)
for(int z=1;z<=k;z++)
{
dp[i][j][z]=(dp[i-1][j-1][z-1]*j)%mod2;
if(z>=a[i]){
dp[i][j][z]+=dp[i-1][j][z-a[i]]*2*j%mod2,
dp[i][j][z]%=mod2;}
if(z>=a[i]*2-1){
dp[i][j][z] += (dp[i - 1][j + 1][z- a[i] * 2 + 1] * j % mod2) % mod2,
dp[i][j][z]%=mod2;}
}
s2=0;
for(int i = 1; i <= k; ++i){
s2 += dp[n][1][i] * C(k - i + n, n) % mod2;
s2 %= mod2;
}
cout << s2;
}
Compilation message
Main.cpp:40:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
40 | main()
| ^~~~
Main.cpp: In function 'void phongbeo()':
Main.cpp:61:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
61 | for(int i=1;i<=n;i++)
| ^~~
Main.cpp:63:6: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
63 | sort(a+1,a+1+n);
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
131 ms |
142416 KB |
Output is correct |
2 |
Correct |
10 ms |
64600 KB |
Output is correct |
3 |
Correct |
9 ms |
33884 KB |
Output is correct |
4 |
Correct |
5 ms |
19804 KB |
Output is correct |
5 |
Correct |
13 ms |
56156 KB |
Output is correct |
6 |
Correct |
40 ms |
73764 KB |
Output is correct |
7 |
Correct |
43 ms |
103248 KB |
Output is correct |
8 |
Correct |
1 ms |
8792 KB |
Output is correct |
9 |
Correct |
20 ms |
78684 KB |
Output is correct |
10 |
Correct |
1 ms |
9052 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
32092 KB |
Output is correct |
2 |
Correct |
4 ms |
15196 KB |
Output is correct |
3 |
Correct |
9 ms |
32092 KB |
Output is correct |
4 |
Correct |
4 ms |
19600 KB |
Output is correct |
5 |
Correct |
8 ms |
32092 KB |
Output is correct |
6 |
Correct |
4 ms |
21340 KB |
Output is correct |
7 |
Correct |
8 ms |
32348 KB |
Output is correct |
8 |
Correct |
4 ms |
27228 KB |
Output is correct |
9 |
Correct |
3 ms |
19380 KB |
Output is correct |
10 |
Correct |
2 ms |
9052 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
61532 KB |
Output is correct |
2 |
Correct |
6 ms |
49756 KB |
Output is correct |
3 |
Correct |
9 ms |
63440 KB |
Output is correct |
4 |
Correct |
7 ms |
53852 KB |
Output is correct |
5 |
Correct |
8 ms |
63404 KB |
Output is correct |
6 |
Correct |
6 ms |
45660 KB |
Output is correct |
7 |
Correct |
8 ms |
61448 KB |
Output is correct |
8 |
Correct |
3 ms |
27228 KB |
Output is correct |
9 |
Correct |
7 ms |
53852 KB |
Output is correct |
10 |
Correct |
3 ms |
27228 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
131 ms |
142416 KB |
Output is correct |
2 |
Correct |
10 ms |
64600 KB |
Output is correct |
3 |
Correct |
9 ms |
33884 KB |
Output is correct |
4 |
Correct |
5 ms |
19804 KB |
Output is correct |
5 |
Correct |
13 ms |
56156 KB |
Output is correct |
6 |
Correct |
40 ms |
73764 KB |
Output is correct |
7 |
Correct |
43 ms |
103248 KB |
Output is correct |
8 |
Correct |
1 ms |
8792 KB |
Output is correct |
9 |
Correct |
20 ms |
78684 KB |
Output is correct |
10 |
Correct |
1 ms |
9052 KB |
Output is correct |
11 |
Correct |
8 ms |
32092 KB |
Output is correct |
12 |
Correct |
4 ms |
15196 KB |
Output is correct |
13 |
Correct |
9 ms |
32092 KB |
Output is correct |
14 |
Correct |
4 ms |
19600 KB |
Output is correct |
15 |
Correct |
8 ms |
32092 KB |
Output is correct |
16 |
Correct |
4 ms |
21340 KB |
Output is correct |
17 |
Correct |
8 ms |
32348 KB |
Output is correct |
18 |
Correct |
4 ms |
27228 KB |
Output is correct |
19 |
Correct |
3 ms |
19380 KB |
Output is correct |
20 |
Correct |
2 ms |
9052 KB |
Output is correct |
21 |
Correct |
9 ms |
61532 KB |
Output is correct |
22 |
Correct |
6 ms |
49756 KB |
Output is correct |
23 |
Correct |
9 ms |
63440 KB |
Output is correct |
24 |
Correct |
7 ms |
53852 KB |
Output is correct |
25 |
Correct |
8 ms |
63404 KB |
Output is correct |
26 |
Correct |
6 ms |
45660 KB |
Output is correct |
27 |
Correct |
8 ms |
61448 KB |
Output is correct |
28 |
Correct |
3 ms |
27228 KB |
Output is correct |
29 |
Correct |
7 ms |
53852 KB |
Output is correct |
30 |
Correct |
3 ms |
27228 KB |
Output is correct |
31 |
Correct |
132 ms |
144636 KB |
Output is correct |
32 |
Correct |
79 ms |
114256 KB |
Output is correct |
33 |
Correct |
125 ms |
144592 KB |
Output is correct |
34 |
Correct |
32 ms |
71508 KB |
Output is correct |
35 |
Correct |
129 ms |
144796 KB |
Output is correct |
36 |
Correct |
10 ms |
40024 KB |
Output is correct |
37 |
Correct |
125 ms |
143128 KB |
Output is correct |
38 |
Correct |
27 ms |
76368 KB |
Output is correct |
39 |
Correct |
124 ms |
142928 KB |
Output is correct |
40 |
Correct |
44 ms |
73908 KB |
Output is correct |
41 |
Correct |
127 ms |
143124 KB |
Output is correct |
42 |
Correct |
4 ms |
25432 KB |
Output is correct |
43 |
Correct |
126 ms |
142364 KB |
Output is correct |
44 |
Correct |
15 ms |
50396 KB |
Output is correct |
45 |
Correct |
130 ms |
143096 KB |
Output is correct |
46 |
Correct |
3 ms |
13660 KB |
Output is correct |
47 |
Correct |
23 ms |
77144 KB |
Output is correct |
48 |
Correct |
15 ms |
71004 KB |
Output is correct |
49 |
Correct |
4 ms |
25688 KB |
Output is correct |
50 |
Correct |
4 ms |
29276 KB |
Output is correct |