QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#619337#9107. Zayin and CounttreasuresgcWA 32ms3848kbC++231.4kb2024-10-07 13:54:552024-10-07 13:54:55

Judging History

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

  • [2024-10-07 13:54:55]
  • 评测
  • 测评结果:WA
  • 用时:32ms
  • 内存:3848kb
  • [2024-10-07 13:54:55]
  • 提交

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(b[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(b[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: 32ms
memory: 3848kb

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:

4
1022006237109559880
52755244567262766742575722
5
438229331288051891
41990991999414091249949
5
821768507959693862
101364364636933104003903
4
805854043685654560
57558888789255872922852552
5
1069029608190472452
757222758857875785288225787822
4
1034104857625460635
761161760076076167101117776167
4
8992...

result:

wrong answer 1st lines differ - expected: '52755244567262766742575722', found: '4'