QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#123301 | #5552. Skyscraper | lmeowdn | 15 | 1ms | 4092kb | C++14 | 2.2kb | 2023-07-12 08:59:39 | 2023-07-12 08:59:43 |
Judging History
answer
#include<bits/stdc++.h>
#define fi first
#define se second
#define eb emplace_back
#define mp make_pair
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef __int128 i128;
template<typename T,typename U>
T ceil(T x, U y) {return (x>0?(x+y-1)/y:x/y);}
template<typename T,typename U>
T floor(T x, U y) {return (x>0?x/y:(x-y+1)/y);}
template<class T,class S>
bool chmax(T &a,const S b) {return (a<b?a=b,1:0);}
template<class T,class S>
bool chmin(T &a,const S b) {return (a>b?a=b,1:0);}
int popcnt(int x) {return __builtin_popcount(x);}
int popcnt(ll x) {return __builtin_popcountll(x);}
int topbit(int x) {return (x==0?-1:31-__builtin_clz(x));}
int topbit(ll x) {return (x==0?-1:63-__builtin_clzll(x));}
int lowbit(int x) {return (x==0?-1:__builtin_ctz(x));}
int lowbit(ll x) {return (x==0?-1:__builtin_ctzll(x));}
#define int long long
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vp;
typedef tuple<int,int,int> tiii;
int read() {
int x=0,w=1; char c=getchar();
while(!isdigit(c)) {if(c=='-') w=-1; c=getchar();}
while(isdigit(c)) {x=x*10+(c-'0'); c=getchar();}
return x*w;
}
const int N=105,mod=1e9+7;
int n,k,f[N][N][N][2][2],a[N];
void upd(int i,int j,int p,int x,int y,int val) {
int xp=p+(2*j-x-y)*(a[i]-a[i+1]); if(xp>k) return; if(!val) return;
f[i][j][xp][x][y]=(f[i][j][xp][x][y]+val)%mod;
}
signed main() {
n=read(), k=read();
if(n==1) return puts("1"), 0;
rep(i,1,n) a[i]=read();
f[0][0][0][0][0]=1;
sort(a+1,a+n+1,greater<int>());
rep(i,1,n) {
rep(j,0,i) {
rep(p,0,k) {
rep(x,0,1) rep(y,0,1) {
int v=f[i-1][j][p][x][y];
if(j&&!x) upd(i,j,p,1,y,v);
if(!x) upd(i,j+1,p,1,y,v);
if(j&&!y) upd(i,j,p,x,1,v);
if(!y) upd(i,j+1,p,x,1,v);
upd(i,j,p,x,y,v*(2*j-x-y)%mod);
upd(i,j+1,p,x,y,v*(j+1-x-y)%mod);
upd(i,j-1,p,x,y,v*(j-1)%mod);
}
}
}
}
int ans=0;
rep(p,0,k) ans=(ans+f[n][1][p][1][1])%mod;
printf("%lld\n",ans);
return 0;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 5
Accepted
time: 1ms
memory: 3424kb
input:
1 1 8
output:
1
result:
ok single line: '1'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3672kb
input:
2 6 10 4
output:
2
result:
ok single line: '2'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3664kb
input:
3 11 9 1 3
output:
4
result:
ok single line: '4'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
6 94 45 79 24 10 41 66
output:
12
result:
ok single line: '12'
Test #5:
score: -5
Wrong Answer
time: 0ms
memory: 4092kb
input:
8 945 493 43 988 504 328 730 841 613
output:
-54866
result:
wrong answer 1st lines differ - expected: '2', found: '-54866'
Subtask #2:
score: 15
Accepted
Test #11:
score: 15
Accepted
time: 1ms
memory: 3852kb
input:
12 63 8 2 6 3 11 9 1 12 4 5 10 7
output:
472261248
result:
ok single line: '472261248'
Test #12:
score: 0
Accepted
time: 1ms
memory: 3728kb
input:
14 96 17 36 98 27 13 68 11 34 80 50 22 73 94 37
output:
44
result:
ok single line: '44'
Test #13:
score: 0
Accepted
time: 1ms
memory: 3928kb
input:
14 45 6 9 12 15 18 2 14 5 11 17 4 3 7 10
output:
183056086
result:
ok single line: '183056086'
Test #14:
score: 0
Accepted
time: 1ms
memory: 3716kb
input:
14 97 25 2 54 78 9 29 34 99 82 36 14 66 15 64
output:
2
result:
ok single line: '2'
Test #15:
score: 0
Accepted
time: 1ms
memory: 3752kb
input:
14 98 26 70 16 95 30 2 18 96 6 5 52 99 89 24
output:
2
result:
ok single line: '2'
Test #16:
score: 0
Accepted
time: 1ms
memory: 3796kb
input:
14 92 33 3 17 38 39 45 2 48 22 29 9 28 5 10
output:
1235526
result:
ok single line: '1235526'
Test #17:
score: 0
Accepted
time: 1ms
memory: 3800kb
input:
14 29 12 6 16 9 23 20 3 1 8 25 29 26 19 24
output:
2
result:
ok single line: '2'
Test #18:
score: 0
Accepted
time: 1ms
memory: 3812kb
input:
14 43 17 11 7 8 5 2 10 16 12 9 15 3 14 18
output:
110733412
result:
ok single line: '110733412'
Test #19:
score: 0
Accepted
time: 1ms
memory: 3900kb
input:
14 72 7 13 19 16 20 15 4 10 1 6 14 11 5 8
output:
347124497
result:
ok single line: '347124497'
Test #20:
score: 0
Accepted
time: 0ms
memory: 3768kb
input:
14 83 18 73 40 48 86 97 24 21 45 69 36 16 26 35
output:
6
result:
ok single line: '6'
Subtask #3:
score: 0
Skipped
Dependency #1:
0%