QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#105799#6143. 滚榜zaneyu#80 152ms191972kbC++232.8kb2023-05-15 15:03:082024-05-31 13:37:04

Judging History

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

  • [2024-05-31 13:37:04]
  • 评测
  • 测评结果:80
  • 用时:152ms
  • 内存:191972kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-15 15:03:08]
  • 提交

answer

/*input
11 300
6 8 8 12 0 11 6 1 0 15 5
*/
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//#pragma GCC target("avx2")
//order_of_key #of elements less than x
// find_by_order kth element
using ll=long long;
using ld=long double;
using pii=pair<int,int>;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()),c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const ll maxn=5e3+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const int MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-4;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
    out<<P.f<<' '<<P.s;
    return out;
}
template<typename T>
ostream& operator<<(ostream& out,vector<T> V){
    REP(i,sz(V)) out<<V[i]<<((i!=sz(V)-1)?"\n":"");
    return out;
}
ll mult(ll a,ll b){
    return a*b%MOD;
}
ll mypow(ll a,ll b){
    a%=MOD;
    if(a==0) return 0;
    if(b<=0) return 1;
    ll res=1LL;  
    while(b){
        if(b&1) res=(res*a)%MOD;
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
int dp[(1<<13)][13][505];
int arr[maxn];
int main(){
    ios::sync_with_stdio(false),cin.tie(0);
    int n,m;
    cin>>n>>m;
    REP(i,n){
        cin>>arr[i];
    }
    REP(j,n){
        int ans=0;
        REP(k,n){
            int need=max(0,arr[k]-arr[j]+(j>k));
            MXTO(ans,need);
        }
        dp[(1<<j)][j][ans*n]=1;
    }
    REP1(i,(1<<n)-1){
        int cn=__builtin_popcount(i);
        if(cn<=1) continue;
        REP(j,n){
            if(i&(1<<j)){
                REP(k,n){
                    if(k==j) continue;
                    if((i&(1<<k))){
                        int need=max(0,arr[k]-arr[j]+(j>k));
                        REP(a,m+1){
                            int nw=a+need*(n-cn+1);
                            if(nw>m) break;
                            dp[i][j][nw]+=dp[i^(1<<j)][k][a];
                            if(dp[i][j][nw]>=MOD) dp[i][j][a+need*(n-cn)]-=MOD;
                        }
                    }
                }
                /*REP(a,m+1){
                    if(dp[i][j][a]) cout<<i<<' '<<j<<' '<<a<<' '<<dp[i][j][a]<<'\n';
                }*/
            }
        }
    }
    int ans=0;
    REP(i,n) REP(j,m+1) ans+=dp[(1<<n)-1][i][j],ans%=MOD;
    cout<<ans;
}

详细

Test #1:

score: 5
Accepted
time: 0ms
memory: 3860kb

input:

2 8
8950 8954

output:

2

result:

ok 1 number(s): "2"

Test #2:

score: 5
Accepted
time: 0ms
memory: 3564kb

input:

2 10
8841 8843

output:

2

result:

ok 1 number(s): "2"

Test #3:

score: 5
Accepted
time: 0ms
memory: 3588kb

input:

3 9
8765 8761 8765

output:

2

result:

ok 1 number(s): "2"

Test #4:

score: 5
Accepted
time: 0ms
memory: 3640kb

input:

3 8
8385 8385 8387

output:

6

result:

ok 1 number(s): "6"

Test #5:

score: 5
Accepted
time: 0ms
memory: 3624kb

input:

3 9
8581 8585 8582

output:

2

result:

ok 1 number(s): "2"

Test #6:

score: 5
Accepted
time: 2ms
memory: 8960kb

input:

8 100
8856 8864 8858 8860 8856 8863 8859 8857

output:

17589

result:

ok 1 number(s): "17589"

Test #7:

score: 5
Accepted
time: 2ms
memory: 8924kb

input:

8 100
8238 8239 8245 8244 8245 8244 8238 8244

output:

32475

result:

ok 1 number(s): "32475"

Test #8:

score: 5
Accepted
time: 2ms
memory: 8904kb

input:

8 100
9804 9806 9807 9802 9801 9803 9801 9806

output:

37012

result:

ok 1 number(s): "37012"

Test #9:

score: 5
Accepted
time: 4ms
memory: 23288kb

input:

10 200
8002 8014 8011 8013 8002 8003 8002 8016 8009 8004

output:

606309

result:

ok 1 number(s): "606309"

Test #10:

score: 5
Accepted
time: 8ms
memory: 23308kb

input:

10 200
8324 8323 8328 8322 8325 8328 8328 8323 8334 8323

output:

2504995

result:

ok 1 number(s): "2504995"

Test #11:

score: 5
Accepted
time: 6ms
memory: 23320kb

input:

10 200
9416 9415 9417 9404 9408 9409 9410 9416 9415 9411

output:

2553164

result:

ok 1 number(s): "2553164"

Test #12:

score: 5
Accepted
time: 6ms
memory: 24600kb

input:

10 200
9422 9430 9425 9425 9425 9423 9431 9428 9432 9434

output:

2687280

result:

ok 1 number(s): "2687280"

Test #13:

score: 5
Accepted
time: 38ms
memory: 90456kb

input:

12 300
9281 9292 9279 9280 9289 9291 9285 9279 9280 9281 9290 9281

output:

197821618

result:

ok 1 number(s): "197821618"

Test #14:

score: 5
Accepted
time: 36ms
memory: 90264kb

input:

12 300
9737 9726 9731 9736 9723 9727 9722 9732 9736 9733 9737 9728

output:

196607151

result:

ok 1 number(s): "196607151"

Test #15:

score: 5
Accepted
time: 49ms
memory: 91572kb

input:

12 300
8707 8708 8712 8704 8705 8704 8716 8711 8713 8712 8702 8710

output:

337047589

result:

ok 1 number(s): "337047589"

Test #16:

score: 5
Accepted
time: 39ms
memory: 91672kb

input:

12 300
9200 9194 9191 9195 9197 9192 9206 9206 9197 9198 9192 9202

output:

164570332

result:

ok 1 number(s): "164570332"

Test #17:

score: 0
Wrong Answer
time: 139ms
memory: 191276kb

input:

13 500
8217 8233 8238 8217 8237 8237 8217 8217 8230 8234 8225 8223 8220

output:

500488812

result:

wrong answer 1st numbers differ - expected: '1500488819', found: '500488812'

Test #18:

score: 0
Wrong Answer
time: 148ms
memory: 191552kb

input:

13 500
9781 9780 9772 9779 9785 9788 9788 9777 9791 9784 9782 9777 9768

output:

627756406

result:

wrong answer 1st numbers differ - expected: '4627756434', found: '627756406'

Test #19:

score: 0
Wrong Answer
time: 152ms
memory: 191972kb

input:

13 500
8096 8078 8103 8104 8085 8089 8081 8085 8102 8095 8097 8100 8090

output:

388414338

result:

wrong answer 1st numbers differ - expected: '1388414345', found: '388414338'

Test #20:

score: 0
Wrong Answer
time: 151ms
memory: 190960kb

input:

13 500
8739 8728 8743 8727 8730 8735 8733 8738 8731 8743 8728 8722 8722

output:

106123698

result:

wrong answer 1st numbers differ - expected: '3106123719', found: '106123698'