QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#123300#5552. Skyscraperlmeowdn15 2ms3920kbC++142.2kb2023-07-12 08:58:512023-07-12 08:58:54

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 08:58:54]
  • 评测
  • 测评结果:15
  • 用时:2ms
  • 内存:3920kb
  • [2023-07-12 08:58:51]
  • 提交

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();
  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;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3584kb

input:

1 1
8

output:

0

result:

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

Subtask #2:

score: 15
Accepted

Test #11:

score: 15
Accepted
time: 1ms
memory: 3892kb

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

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

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

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

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: 2ms
memory: 3880kb

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

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

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

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%