QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#273422 | #6132. Repair the Artwork | teafrogsf | WA | 54ms | 9928kb | C++14 | 1.5kb | 2023-12-02 23:47:06 | 2023-12-02 23:47:06 |
Judging History
answer
#include<cstdio>
#include<algorithm>
#include<vector>
#define pb push_back
#define f(i,a,b) for(int i=(a),i##end=(b);i<=i##end;i=-(~i))
#define rf(i,a,b) for(int i=(a),i##end=(b);i>=i##end;i=~(-i))
using namespace std;
using ll=long long;
const int neko=110,mod=1e9+7;
int ADD(int x,int y){return x+y>=mod?x+y-mod:x+y;}
int n,m,a[neko];
int dp[neko][neko*neko][2];//dp[i][j][k]表示考虑前i个,有j个合法区间,前面有偶数/奇数个1
int lim[neko];
int spow(int m,int n)
{
int b=1;
for(;n;n>>=1,m=1ll*m*m%mod)if(n&1)b=1ll*b*m%mod;
return b;
}
int main()
{
int cas;
scanf("%d",&cas);
while(cas--)
{
scanf("%d%d",&n,&m);
int flag=0;
f(i,1,n)
{scanf("%d",&a[i]);if(a[i]==1)flag^=1;}
a[0]=a[n+1]=1;
dp[0][0][0]=0,dp[0][0][1]=1,lim[0]=0;
int las=0;
f(i,1,n+1)if(a[i]>0)
{
lim[i]=lim[las]+(i-las)*(i-las-1)/2;
f(j,0,lim[i])dp[i][j][0]=dp[i][j][1]=0;
f(l,las,i-1)if(a[l]>0)
{
int delta=(i-l)*(i-l-1)/2;
f(j,0,lim[l])
f(k,0,1)
dp[i][j+delta][k]=ADD(dp[i][j+delta][k],dp[l][j][k^1]);
}
if(a[i]==1)las=i;
}
int ans=0;
f(j,0,lim[n+1])ans=ADD(ans,1ll*ADD(dp[n+1][j][0],mod-dp[n+1][j][1])*spow(j,m)%mod);
if(flag==1)ans=ADD(mod,mod-ans);
printf("%d\n",ans);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 1556kb
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: 0
Accepted
time: 1ms
memory: 5644kb
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:
ok 100 numbers
Test #3:
score: -100
Wrong Answer
time: 54ms
memory: 9928kb
input:
1000 20 673037423 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 774964932 2 2 2 17 730319736 2 2 1 1 2 2 2 2 2 2 2 2 2 1 2 2 1 11 893285699 2 2 2 1 2 1 2 2 2 1 2 16 98149251 1 2 1 2 1 2 1 1 2 1 2 2 2 2 1 2 7 556953277 1 2 2 1 2 2 2 3 228111342 1 1 1 11 640995044 2 2 1 1 2 2 1 1 1 1 1 19 741419324 1 1 2 ...
output:
447486147 204414804 452414918 684654914 763978130 805973365 1000000007 922180033 214948715 401017738 1000000007 201368027 752718484 611006275 848004989 391560729 950934074 202096866 443534870 24665646 482580424 321199514 922369975 152629767 5546104 1 194145234 1 1 1 562381239 648246425 497517379 217...
result:
wrong answer 7th numbers differ - expected: '0', found: '1000000007'