QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#504469 | #9107. Zayin and Count | Afterlife# | WA | 46ms | 3876kb | C++20 | 2.4kb | 2024-08-04 13:20:52 | 2024-08-04 13:20:52 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
using ll=__int128;
const int N=71;
int T;
ll f[N][2][2];
int a[10],b[10];
string s;
ll dfs(int x,int lead,int up)
{
if(x==s.size())
return !lead;
if(f[x][lead][up]!=-1)
return f[x][lead][up];
ll &ret=f[x][lead][up];
ret=0;
for(int i=0;i<=(up?s[x]-'0':9);i++)
{
if(!a[i])
continue;
int nlead=lead&&!i;
int nup=up&&i==s[x]-'0';
ret+=dfs(x+1,nlead,nup);
}
return ret;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin>>T;
while(T--)
{
memset(f,-1,sizeof(f));
for(int i=0;i<10;i++)
cin>>a[i];
for(int i=0;i<10;i++)
cin>>b[i];
cin>>s;
ll cnt=dfs(0,1,1);
if(a[0])
cnt++;
if(b[0])
{
if(cnt==1)
{
cout<<"0\n";
continue;
}
cnt--;
}
int cb=accumulate(b,b+10,0);
vector<ll> pw({1});
ll S=0;
for(int i=1;;i++)
{
ll ways=pw.back();
int fd=0;
for(int j=1;j<10;j++)
{
if(!b[j])
continue;
if(S+ways>=cnt)
{
string ans;
ans+=to_string(j);
pw.pop_back();
for(int k=i-1;k>=1;k--)
{
ll ways=pw.back();
pw.pop_back();
for(int j=0;j<10;j++)
{
if(!b[j])
continue;
if(S+ways>=cnt)
{
ans+=to_string(j);
break;
}
else
S+=ways;
}
}
cout<<ans<<"\n";
fd=1;
break;
}
else
S+=ways;
}
if(fd)
break;
pw.push_back(pw.back()*cb);
}
}
}
详细
Test #1:
score: 0
Wrong Answer
time: 46ms
memory: 3876kb
input:
10000 1 0 0 0 1 1 0 0 0 1 0 0 1 0 1 1 1 1 0 0 950595954440050004054505054050 1 0 0 0 1 1 1 1 0 0 1 1 1 0 1 0 0 0 1 1 45467007076660767550460064 1 1 1 1 0 0 0 1 0 0 1 1 0 1 1 0 1 0 0 1 23373171320213300170200722 0 0 0 0 1 1 1 0 1 0 0 0 1 0 0 1 0 1 1 1 558565664666565565558468668484 1 1 0 0 1 0 1 0 1 ...
output:
52755244567262766742575722 41990991999414091249949 101364364636933104003903 22927899885892885529795855 757222758857875785288225787822 610010606760761011770006661017 56666586555668686566656586856566686658 6151651151611161656161551615155651516 505885888775005550558080707878 2222392999369366212233199 6...
result:
wrong answer 4th lines differ - expected: '57558888789255872922852552', found: '22927899885892885529795855'