QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#575407 | #9107. Zayin and Count | leafmaple# | WA | 26ms | 3840kb | C++20 | 3.0kb | 2024-09-19 13:52:05 | 2024-09-19 13:52:07 |
Judging History
answer
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
using ll = long long;
const int N=1e6+5;
#define int unsigned long long
int cal(vector<int> vec, string s){
int cnt = 0;
int tot = 0;
map<int,int>mp;
if(vec[0] == 1){
for(int i=0; i<10; i++) if(vec[i]) {
cnt++;
mp[i] = tot++;
}
for(auto &c: s){
int x = c-'0';
c = mp[x] + '0';
}
int ans = 0;
for(int i=0; i<s.size(); i++){
ans = ans * cnt + s[i]-'0';
}
return ans+1;
}else {
for(int i=0; i<10; i++) if(vec[i]) {
cnt++;
mp[i] = ++tot;
}
for(auto &c: s){
int x = c-'0';
c = mp[x] + '0';
}
int ans = 0;
for(int i=0; i<s.size(); i++){
ans = ans * cnt + s[i]-'0';
}
return ans;
}
}
void fk(vector<int>vec, int k){
map<int,int>mp;
int cnt = 0, tot = 0;
if(vec[0] == 1){
k-=1;
for(int i=0; i<10; i++) if(vec[i]) {
cnt++;
mp[tot++] = i;
}
string ans;
while(k){
ans += k%cnt + '0';
k /= cnt;
}
for(auto &c: ans){
c = mp[c-'0'] + '0';
}
reverse(ans.begin(), ans.end());
cout << ans << endl;
return ;
}
for(int i=0; i<10; i++) if(vec[i]) {
cnt++;
mp[++tot] = i;
}
vector<int>pk(200); pk[0] = 1;
for(int i=1; i<=64; i++) pk[i] = pk[i-1]*cnt;
int sum = 0;
for(int i=0; i<=64;i++)
{
sum += pk[i]*cnt;
if(sum >= k)
{
sum -= pk[i]*cnt;
k -= sum ;
sum = 0;
for(int j=i;j>=0;j--)
{
//cout<<k<<" "<<sum<<endl;
for(int l = 1;l<=cnt ;l++)
{
//cout<<"case"<<' '<<j<<" "<<endl;
if(pk[j]*l >= k)
{
//cout<<pk[j]*l<<' '<<k<<endl;
cout<<mp[l];
k -=pk[j]*(l - 1);
// cout<<l<<endl;
break;
}
}
//cout<<k<<endl;
// cout<<sum<<endl;
sum = 0 ;
if(j == 0)break;
}
return ;
}
}
}
void solve(){
vector<int>a(15), b(15);
for(int i=0; i<10; i++) cin >> a[i];
for(int i=0; i<10; i++) cin >> b[i];
string x; cin >> x;
int k = cal(a, x);
// cout << k << endl;
fk(b, k);
}
signed main(){
cin.tie(0)->sync_with_stdio(0);
int T; T=1;
cin >> T;
while(T--) solve();
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 26ms
memory: 3840kb
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:
5275524456726276674257572241990991999414091249949 101364364636933104003903 57558888789255872922852552757222758857875785288225787822761161760076076167101117776167 5666658655566868656665658685656668665815611661611611111511116116661611616155505885888775005550558080707878 3912911219633669993999199888568...
result:
wrong answer 1st lines differ - expected: '52755244567262766742575722', found: '5275524456726276674257572241990991999414091249949'