QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#196567 | #6517. Computational Geometry | ucup-team870# | WA | 0ms | 5932kb | C++14 | 2.0kb | 2023-10-01 19:21:29 | 2023-10-01 19:21:29 |
Judging History
answer
#include <bits/stdc++.h>
#define For(i,l,r) for(int i=l; i<=r; i++)
#define per(i,l,r) for(int i=l;i>=r;i--)
#define IOS {cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);}
using namespace std;
typedef long long ll;
const int mo=998244353;
int a[11]; ll dp[13][53][13][53];
ll c[53][53];
void init(){
For(i,0,50) c[i][0]=1;
For(i,1,50) For(j,1,i) c[i][j]=(c[i-1][j-1]+c[i-1][j])%mo;
}
ll cal(int n){
if (!n){
int ma=-1,ii;
For(i,0,9) if (a[i]>=ma) ma=a[i],ii=i;
return ii;
}
For(i,0,9) For(j,0,n) memset(dp[i][j],0,sizeof(dp[i][j]));
For(i,0,n) dp[0][i][0][i+a[0]]=c[n][i];
For(i,0,8) For(j,0,n) For(k,0,i) For(l,0,n) if (dp[i][j][k][l]){
ll tmp=dp[i][j][k][l];
For(d,0,n-j){
int now=a[i+1]+d;
if (l>now) dp[i+1][d+j][k][l]=(dp[i+1][d+j][k][l]+c[n-j][d]*tmp)%mo;
else dp[i+1][d+j][i+1][d+a[i+1]]=(dp[i+1][d+j][i+1][d+a[i+1]]+c[n-j][d]*tmp)%mo;
}
}
ll ans=0;
For(k,0,9) For(l,1,n){
if (n==1) cout<<k<<' '<<l<<' '<<dp[9][n][k][l]<<endl;
ans+=dp[9][n][k][l]*k%mo;
}
return ans%mo;
}
ll ani[53];
char ch[53];
ll work(int n){
ll ans=0;
For(i,1,n){
int mi=0; if (i==1) mi=1;
int ma=ch[i]-1; if (i==n) ma=ch[i];
For(j,mi,ma){
++a[j]; ans+=cal(n-i); --a[j];
}
++a[ch[i]];
}
return ans%mo;
}
int main(){
init();
For(i,1,2){
For(j,1,9){
memset(a,0,40);
a[j]=1;
ani[i]+=cal(i-1);
cout<<endl;
}
ani[i]%=mo;
}
int ss=0;
For(i,1,6){
ss+=ani[i];
cout<<' '<<ss<<endl;
}
int _; cin>>_;
while(_--){
scanf("%s",ch+1);
int n=strlen(ch+1);
memset(a,0,40);
ll ans=0;
For(i,1,n-1) ans+=ani[i];
For(i,1,n) ch[i]-=48;
ans+=work(n);
printf("%lld\n",ans%mo);
}
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 5932kb
input:
2 4 1 0 2 0 1 1 0 0 6 10 4 9 7 5 7 4 5 6 4 9 3
output:
0 1 0 1 1 1 2 1 1 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1 0 1 0 1 1 0 2 1 2 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1 0 1 0 1 1 0 2 1 0 3 1 3 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1 0 1 0 1 1 0 2 1 0 3 1 0 4 1 4 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1 0 1 0 1 1 0 2 1 0 3 1 0 4 1 0 5 1 5 6 1 1 7 1 1...
result:
wrong answer 1st numbers differ - expected: '4', found: '0'