QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#471477#9107. Zayin and Countreal_sigma_team#WA 13ms3564kbC++231.7kb2024-07-10 21:26:462024-07-10 21:26:46

Judging History

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

  • [2024-07-10 21:26:46]
  • 评测
  • 测评结果:WA
  • 用时:13ms
  • 内存:3564kb
  • [2024-07-10 21:26:46]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#ifdef lisie_bimbi
#else
#define endl '\n'
#endif

#pragma GCC optimize("O2")
#define int long long
typedef long long ll;

void solve(){
    vector<ll> a(10), b(10);
    for(int i = 0; i < 10; i++){
        cin >> a[i];
    }
    for(int i = 0; i < 10; i++){
        cin >> b[i];
    }
    for(int i = 1; i < 10; i++){
        a[i] += a[i - 1];
    }
    string s;
    cin >> s;
    int n = s.size();
    vector<int> st(n);
    st[0] = 1;
    for(int i = 1; i < n; i++){
        st[i] = st[i - 1] * a[9];
    }
    __int128 x = 0;
    for(int i = 0; i < n; i++){
        int t = s[i] - '0';
        t = a[t] - 1;
        x += t * st[n - i - 1];
    }
    vector<int> b1;
    for(int i = 0; i < 10; i++){
        if(b[i]){
            b1.push_back(i);
        }
    }
    string ans;
    int sz = b1.size();
    if(b[0]){
        while(x > 0){
            ans += ('0' + b1[x % sz]);
            x /= sz;
        }
        reverse(ans.begin(), ans.end());
        if(ans.empty()){
            ans += '0';
        }
        cout << ans << endl;
    }else{
        x++;
        __int128 s = 1;
        while(s < x){
            x -= s;
            s *= sz;
        }
        while(x > 0){
            ans += ('0' + b1[x % sz]);
            x /= sz;
        }
        reverse(ans.begin(), ans.end());
        if(ans.empty()){
            ans += '0';
        }
        cout << ans << endl;
    }
}

signed main(){
#ifdef lisie_bimbi
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);    
#endif     
    ll t;
    cin >> t;
    while(t--){
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 13ms
memory: 3564kb

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:

52755244567262766742575722
41990991999414091249949
101364364636933104003903
927899885892885529795855
757222758857875785288225787822
610010606760761011770006661017
6666586555668686566656586856566686658
6151651151611161656161551615155651516
505885888775005550558080707878
2222392999369366212233199
6868...

result:

wrong answer 4th lines differ - expected: '57558888789255872922852552', found: '927899885892885529795855'