QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#504550#9107. Zayin and CountIllusionaryDominance#RE 0ms0kbC++141.4kb2024-08-04 13:47:562024-08-04 13:47:56

Judging History

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

  • [2024-08-04 13:47:56]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-08-04 13:47:56]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int A[10], B[10], rnkA[20], idsB[20];
int main(){
    ios::sync_with_stdio(0); cin.tie(0), cout.tie(0);
    int T; cin >> T;
    while(T --){
        for (int i = 0; i <= 9; ++ i) cin >> A[i];
        int totA = 0;
        for (int i = 0; i <= 9; ++ i) if(A[i]) rnkA[i] = ++ totA;
        for (int i = 0; i <= 9; ++ i) cin >> B[i];
        int totB = 0;
        for (int i = 0; i <= 9; ++ i) if(B[i]) idsB[++ totB] = i;
        __int128 x = 0;
        char s[10000];
        cin >> s + 1; int n = strlen(s + 1);
        for (int i = 1; i <= n; ++ i) x = x * totA + rnkA[s[i] - '0'];
        __int128 pw = totA;
        for (int i = 2; i <= n; ++ i){
            x -= A[0] * pw;
            pw *= totA;
        }
        if(x <= totB) cout << idsB[x] << "\n";
        else{
            __int128 now = totB, pw = totB, len = 1;
            while(now + pw * (totB - A[0]) < x){
                now += pw * (totB - A[0]);
                ++ len;
                pw = pw * totB;
            }
            int fir = 1 + A[0];
            while(now + pw < x) ++ fir, now += pw;
            x -= now + 1;
            cout << idsB[fir];
            for (int i = 1; i <= len; ++ i){
                pw /= totB;
                cout << idsB[x / totB + 1];
                x %= pw;
            }
        }
        
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

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:


result: