QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#93251#6132. Repair the ArtworklamWA 2ms7556kbC++141.5kb2023-03-31 15:48:502023-03-31 15:48:53

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-31 15:48:53]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:7556kb
  • [2023-03-31 15:48:50]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
using namespace std;
const int maxn = 110LL;
const int mod = 1e9 + 7;
int n,m;
int a[maxn];
int lim[maxn];
int dp[maxn][maxn*maxn/2][2];
int ppow(int x, int y)
{
    int temp=1LL;
    while (y)
    {
        if (y&1) temp=temp*x%mod;
        x=x*x%mod;
        y/=2;
    }
    return temp;
}

void xuly()
{
    cin>>n>>m;
    for (int i=1; i<=n; i++) cin>>a[i];
    a[0]=a[n+1]=1;
    dp[0][0][1] = 1LL;
    int mmax = 0;
    lim[0] = 0;
    for (int i=1,last=0; i<=n+1; i++)
    {
        lim[i] = lim[i-1]+(i-last)*(i-last-1)/2;
        for (int j=0; j<=lim[i]; j++) dp[i][j][0] = dp[i][j][1] = 0LL;
        for (int j=last; j<i; j++)
        {
            if (a[j]==0) continue;
            int val = (i-j)*(i-j-1)/2;
            for (int k=0; k<=lim[j]; k++)
                for (int type=0; type<2; type++)
                    if (dp[j][k][type])
                        dp[i][k+val][type^1] = (dp[i][k+val][type^1] + dp[j][k][type])%mod;
        }
        if (a[i]==1) last=i;
    }
    int ans = 0;
    int sum = 0;
    for (int i=0; i<=n+1; i++) if (a[i]==1) sum++;
    for (int j=0; j<=lim[n+1]; j++)
    {
        ans = (ans + (dp[n+1][j][0] - dp[n+1][j][1] + mod)%mod*ppow(j,m)%mod)%mod;
    }
    if (sum%2==1) ans = (mod-ans)%mod;
    ans=(ans+mod)%mod;
    cout<<ans<<'\n';
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int tt; cin>>tt;
    while (tt--) xuly();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3356kb

input:

3
2 2
2 0
3 2
2 1 0
3 1
2 1 0

output:

8
3
1

result:

ok 3 number(s): "8 3 1"

Test #2:

score: -100
Wrong Answer
time: 2ms
memory: 7556kb

input:

100
2 1
0 1
2 1
2 1
2 1
1 1
1 6
2
1 14
2
3 12
2 2 2
6 13
2 2 0 2 0 2
7 14
0 0 0 0 2 2 0
5 8
2 2 0 0 0
5 5
2 2 0 0 0
12 3
0 2 0 2 2 0 1 2 2 2 2 0
7 11
2 2 0 1 0 1 0
4 4
2 1 2 2
7 5
1 1 0 0 1 0 0
2 14
2 1
15 17
2 2 1 2 0 0 0 0 2 0 1 0 0 0 0
15 11
1 1 2 0 1 2 0 0 1 0 2 1 1 1 1
15 18
1 0 1 0 2 2 1 2 0 1...

output:

1
1
0
1
1
175715347
833406719
467966815
458805426
650344
2208
537089254
146
7776
1
703335050
123067364
355668256
487954758
53774922
544070885
436748805
369291507
760487845
513270785
501075264
487417783
464534262
979007529
137956839
143317512
648268264
851188473
702545117
946416372
595191705
35054850...

result:

wrong answer 96th numbers differ - expected: '344490809', found: '770569005'