QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#619322#9107. Zayin and CounttreasuresgcWA 20ms3548kbC++231.4kb2024-10-07 13:52:362024-10-07 13:52:36

Judging History

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

  • [2024-10-07 13:52:36]
  • 评测
  • 测评结果:WA
  • 用时:20ms
  • 内存:3548kb
  • [2024-10-07 13:52:36]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define i128 __int128
#define int long long
void solve(){
	vector<int>a, b;
	vector<int> ta(11), tb(11);
	for(int i = 0; i <= 9; ++ i){
		int x; cin >> x;
		if(x == 0) ta[i] = -1;
		else {
			ta[i] = a.size();
			a.push_back(i);
		}
	}
	for(int i = 0; i <= 9; ++ i){
		int x; cin >> x;
		if(x == 0) tb[i] = -1;
		else {
			tb[i] = b.size();
			b.push_back(i);
		}
	}
	string str; cin >> str;
	i128 ss = 0, ka = a.size(), kb = b.size();
	if(a[0] == 0){
		int p = 1;
		for(int i = str.size() - 1; i >= 0; -- i){
			char ch = str[i]; 
			ss += p * ta[(ch - '0')];
			p = p * ka;
		} 
	}else{
		i128 p = ka;
		for(int i = 1; i <= str.size() - 1; ++ i){
			ss += p;
			p = p * ka;
		}
		p = 1;
		for(int i = str.size() - 1; i >= 0; -- i){
			char ch = str[i];
			ss += p * ta[(ch - '0')];
			p = p * ka;
		}
	}
//	cout << (int)ka << endl;
//	cout << (int)ss << endl;
	vector<int>ans;
	if(b[0] == 0){
		i128 p = 1;
		while(ss){
			ans.push_back(tb[ss % kb]);
			ss = ss / kb;
		}
	}else{
		int siz = 1;
		i128 p = kb, tt = kb;
		while(p <= ss){
			ss -= p;
			p = p * kb;
			siz ++;
		}
		for(int i = 1; i <= siz; ++ i){
			ans.push_back(tb[ss % kb]);
			ss = ss / kb;	
		}
	}
	for(int i = ans.size() - 1; i >= 0; -- i){
		cout << ans[i];
	}
	cout << endl;
}
signed main(){
	ios::sync_with_stdio(0);
	int T;
	cin >> T;
	while(T--) solve();
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 20ms
memory: 3548kb

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:

0-1100-1-1-10-11-1-1-11-1-11-1-10101-1-1
-11-1-10-1-11-1-1-1-11-10-112-1-1-1-1-1
101-132-1323-13-1-1-110200-1-10-1
-10-1-1-1-1-1-10-1-1-1-1-1-10-1-1-1-1-1-1-1-1-1-1
0-10-1-1-10-1-1-1-10-10-10-1-1-1-1-1-1-1-10-10-1-1-1
-1-111-11-1-100-1-10-1-11-1-110111-1-1-1-11-1-1
-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1...

result:

wrong answer 1st lines differ - expected: '52755244567262766742575722', found: '0-1100-1-1-10-11-1-1-11-1-11-1-10101-1-1'