QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#471471#9107. Zayin and Countreal_sigma_team#WA 13ms3552kbC++231.7kb2024-07-10 21:24:352024-07-10 21:24:37

Judging History

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

  • [2024-07-10 21:24:37]
  • 评测
  • 测评结果:WA
  • 用时:13ms
  • 内存:3552kb
  • [2024-07-10 21:24:35]
  • 提交

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();
    x++;
    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{
        __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: 3552kb

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
41990991999414091249980
101364364636933104003904
927899885892885529795855
757222758857875785288225787822
610010606760761011770006661060
6666586555668686566656586856566686658
6151651151611161656161551615155651516
505885888775005550558080707880
2222392999369366212233199
6868...

result:

wrong answer 2nd lines differ - expected: '41990991999414091249949', found: '41990991999414091249980'