QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#504836#9107. Zayin and CountLavender_Field#WA 8ms3596kbC++201.6kb2024-08-04 16:37:492024-08-04 16:37:49

Judging History

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

  • [2024-08-04 16:37:49]
  • 评测
  • 测评结果:WA
  • 用时:8ms
  • 内存:3596kb
  • [2024-08-04 16:37:49]
  • 提交

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;
    int n = 1;
    while (!(x < sum + p * base_b))
        sum += p *= base_b, ++n;
    std::string res;
    while (n--)
    {
        res += '0' | bnum[x % base_b]; 
        x /= base_b;
    }
    std::ranges::reverse(res);
    return res;
}
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();
}

详细

Test #1:

score: 0
Wrong Answer
time: 8ms
memory: 3596kb

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:

65266455722475422254727242
41990991999414091249949
101364364636933104003903
78779999922577987255975772
878555885282288227752558252252
761161760076076167101117776167
68888858668556558688868865568855558868
61156516156155555655561565516156161565
505885888775005550558080707878
9126122331969112219221319
...

result:

wrong answer 1st lines differ - expected: '52755244567262766742575722', found: '65266455722475422254727242'