# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
287880 |
2020-09-01T05:52:34 Z |
최은수(#5768) |
Skyscraper (JOI16_skyscraper) |
C++17 |
|
10 ms |
6016 KB |
#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18;
const int mod=inf;
inline int add(int x,int y)
{
return x+y<mod?x+y:x+y-mod;
}
inline int mul(int x,int y)
{
return(int)((ll)x*y%mod);
}
int dp[260][15][1005];
vector<int>lst[15];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n,l;
cin>>n>>l;
vector<int>v(n);
for(int&t:v)
cin>>t;
for(int i=0;i<1<<n;i++)
lst[__builtin_popcount(i)].eb(i);
for(int i=0;i<n;i++)
dp[1<<i][i][0]=1;
for(int le=1;le<n;le++)
{
for(int&t:lst[le])
{
for(int i=0;i<n;i++)
{
if((t>>i&1)==0)
continue;
for(int j=0;j<n;j++)
{
if((t>>j&1)==1)
continue;
int dif=abs(v[i]-v[j]);
int nx=t|(1<<j);
for(int len=dif;len<=l;len++)
dp[nx][j][len]=add(dp[nx][j][len],dp[t][i][len-dif]);
}
}
}
}
int ans=0;
for(int i=0;i<n;i++)
for(int len=0;len<=l;len++)
ans=add(ans,dp[(1<<n)-1][i][len]);
cout<<ans<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
1152 KB |
Output is correct |
5 |
Correct |
10 ms |
6016 KB |
Output is correct |
6 |
Correct |
8 ms |
5888 KB |
Output is correct |
7 |
Correct |
4 ms |
4736 KB |
Output is correct |
8 |
Correct |
4 ms |
4608 KB |
Output is correct |
9 |
Correct |
10 ms |
6016 KB |
Output is correct |
10 |
Correct |
5 ms |
4736 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
640 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
1152 KB |
Output is correct |
5 |
Correct |
10 ms |
6016 KB |
Output is correct |
6 |
Correct |
8 ms |
5888 KB |
Output is correct |
7 |
Correct |
4 ms |
4736 KB |
Output is correct |
8 |
Correct |
4 ms |
4608 KB |
Output is correct |
9 |
Correct |
10 ms |
6016 KB |
Output is correct |
10 |
Correct |
5 ms |
4736 KB |
Output is correct |
11 |
Runtime error |
2 ms |
640 KB |
Execution killed with signal 11 |
12 |
Halted |
0 ms |
0 KB |
- |