QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#624523#9107. Zayin and Countexpectant#WA 20ms5580kbC++141.2kb2024-10-09 16:01:472024-10-09 16:01:48

Judging History

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

  • [2024-10-09 16:01:48]
  • 评测
  • 测评结果:WA
  • 用时:20ms
  • 内存:5580kb
  • [2024-10-09 16:01:47]
  • 提交

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();
	}
	std::cerr<<(ll)x<<'\n';
	if(!x) ans+=v2[0]+'0';
	else while(x){
		int pos=x%v2.size();
		ans+=v2[pos]+'0',x/=v2.size();
	}
	std::reverse(ans.begin(),ans.end());
	assert(ans.length()==1||ans[0]!='0');
	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: 20ms
memory: 5580kb

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'