QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#624399 | #9107. Zayin and Count | expectant# | WA | 15ms | 5892kb | C++14 | 1.2kb | 2024-10-09 15:45:35 | 2024-10-09 15:45:35 |
Judging History
answer
#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=j;i<=(k);++i)
#define drp(i,j,k) for(int i=j;i>=(k);--i)
#define MAXN 1000005
typedef long long ll;
typedef __int128 i128;
inline int read(){
int x=0;
bool sgn=true;
char ch=getchar();
while(!isdigit(ch)) sgn^=ch=='-',ch=getchar();
while(isdigit(ch)) x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
return sgn?x:-x;
}
inline void chkmin(int &x,int y){x=std::min(x,y);}
int a[MAXN],b[MAXN];
std::string s;
std::vector<int> v1,v2;
inline void init(){
std::vector<int>().swap(v1);
std::vector<int>().swap(v2);
}
inline void solve(){
i128 cur=1,x=0;
std::string ans;
rep(i,0,(int)s.length()-1){
int pos=std::lower_bound(v1.begin(),v1.end(),s[i]-'0')-v1.begin();
x+=pos*cur,cur*=v1.size();
}
if(!x) ans+=v2[0]+'0';
else while(x){
int cur=x%v2.size();
ans+=v2[cur]+'0',x/=v2.size();
}
std::reverse(ans.begin(),ans.end());
std::cout<<ans<<'\n';
}
int main(){
drp(task,read(),1){
init();
rep(i,0,9) a[i]=read();
rep(i,0,9) b[i]=read();
std::cin>>s,std::reverse(s.begin(),s.end());
rep(i,0,9) if(a[i]) v1.push_back(i);
rep(i,0,9) if(b[i]) v2.push_back(i);
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 15ms
memory: 5892kb
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:
65266455722475422254727242 41990991999414091249949 101364364636933104003903 57259252998225997772927975 878555885282288227752558252252 610010606760761011770006661017 68888858668556558688868865568855558868 51566165566155616511615666156611165656 505885888775005550558080707878 3333916221911699323366319 ...
result:
wrong answer 1st lines differ - expected: '52755244567262766742575722', found: '65266455722475422254727242'