QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#504821#9107. Zayin and CountLavender_Field#WA 12ms3536kbC++201.5kb2024-08-04 16:27:032024-08-04 16:27:04

Judging History

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

  • [2024-08-04 16:27:04]
  • 评测
  • 测评结果:WA
  • 用时:12ms
  • 内存:3536kb
  • [2024-08-04 16:27:03]
  • 提交

answer

#include <algorithm>
#include <iostream>
#include <ranges>
#include <string>
#include <vector>
using ULL = unsigned long long;
int a[10], b[10];
int base_a, base_b;
std::vector<int> bnum;
ULL from_string0(const std::string &s)
{
    ULL res = 0;
    for (char c : s)
        res = res * base_a + a[c & 15] - 1;
    return res;
}
ULL from_string1(const std::string &s)
{
    ULL res = 0;
    ULL p = 1;
    for (int i = 1; i < s.size(); ++i)
        res += p *= base_a;
    return res + from_string0(s);
}
std::string to_string0(ULL x)
{
    std::string res;
    do
        res += '0' | bnum[x % base_b];
    while (x /= base_b);
    std::ranges::reverse(res);
    return res;
}
std::string to_string1(ULL x)
{
    ULL sum = 0;
    __int128 p = 1;
    while (!(x < sum + p * base_b))
        sum += p *= base_b;
    return to_string0(x - sum);
}
void solve()
{
    for (int i = 0; i < 10; ++i)
        std::cin >> a[i];
    for (int i = 1; i < 10; ++i)
        a[i] += a[i - 1];
    base_a = a[9];
    bnum.clear();
    for (int i = 0; i < 10; ++i)
    {
        std::cin >> b[i];
        if (b[i]) bnum.push_back(i);
    }
    base_b = bnum.size();
    std::string s; std::cin >> s;
    ULL x = a[0] ? from_string0(s) : from_string1(s);
    // std::cout << x << "\n";
    std::cout << (b[0] ? to_string0(x) : to_string1(x)) << "\n";
}
int main()
{
    std::ios_base::sync_with_stdio(false), std::cin.tie(nullptr);
    int T; std::cin >> T;
    while (T--) solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 12ms
memory: 3536kb

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
57558888789255872922852552
757222758857875785288225787822
761161760076076167101117776167
6666586555668686566656586856566686658
5611661611611111511116116661611616155
505885888775005550558080707878
3912911219633669993999199
88...

result:

wrong answer 7th lines differ - expected: '56666586555668686566656586856566686658', found: '6666586555668686566656586856566686658'