QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#123302#5552. Skyscraperlmeowdn15 1ms3944kbC++142.2kb2023-07-12 09:00:292023-07-12 09:00:32

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-12 09:00:32]
  • 评测
  • 测评结果:15
  • 用时:1ms
  • 内存:3944kb
  • [2023-07-12 09:00:29]
  • 提交

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<=0) 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: 3376kb

input:

1 1
8

output:

1

result:

ok single line: '1'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

2 6
10 4

output:

2

result:

ok single line: '2'

Test #3:

score: 0
Accepted
time: 1ms
memory: 3600kb

input:

3 11
9 1 3

output:

4

result:

ok single line: '4'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3720kb

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: 3944kb

input:

8 945
493 43 988 504 328 730 841 613

output:

3970236

result:

wrong answer 1st lines differ - expected: '2', found: '3970236'

Subtask #2:

score: 15
Accepted

Test #11:

score: 15
Accepted
time: 0ms
memory: 3816kb

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: 0ms
memory: 3772kb

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: 3848kb

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: 3752kb

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: 3732kb

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: 3852kb

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: 3764kb

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: 3808kb

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: 3860kb

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: 1ms
memory: 3744kb

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%