QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#504660#9107. Zayin and CountPlentyOfPenalty#WA 9ms3756kbC++201.8kb2024-08-04 14:34:422024-08-04 14:34:43

Judging History

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

  • [2024-08-04 14:34:43]
  • 评测
  • 测评结果:WA
  • 用时:9ms
  • 内存:3756kb
  • [2024-08-04 14:34:42]
  • 提交

answer

#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define rep(i, l, r) for (int i = (l), i##end = (r); i <= i##end; ++i)
#define per(i, l, r) for (int i = (l), i##end = (r); i >= i##end; --i)
#ifdef memset0
#define log(...) fprintf(stderr, __VA_ARGS__)
#else
#define log(...) (void(0))
#define endl '\n'
#endif
using namespace std;
using ll = long long;
using lf = long double;
using ull = unsigned long long;
using LL = __int128;
const int L = 70;
int T, s1[15], rk1[15], sz1, s2[15], a2[15], sz2;
string str;
LL Enc(int *s, int *a, int n, string t) {
  LL ret = 0;
  if (s[0]) {
    LL pw = 1;
    for (int i = t.size() - 1; i >= 0; --i) ret += pw * a[t[i] - '0'], pw *= n;
  } else {
    LL pw = 1;
    for (int i = 1; i < t.size(); ++i) pw *= n, ret += pw;
    // cerr << "RET=" << (ull)ret << "\n";
    pw = 1;
    for (int i = t.size() - 1; i >= 0; --i) ret += pw * a[t[i] - '0'], pw *= n;
  }
  // cerr << "RET=" << (ull)ret << "\n";
  return ret;
}
int tmp[L + 10], sz;
string Dec(int *s, int *a, int n, LL rk) {
  if (s[0]) {
    while (rk) tmp[++sz] = rk % n, rk /= n;
  } else {
    LL pw = n;
    while (rk > pw) rk -= pw, ++sz, pw *= n;
    for (int i = 1; i <= sz; ++i) tmp[i] = rk % n, rk /= n;
  }
  string ret = "";
  for (int i = sz; i >= 1; --i) ret += a[tmp[i]] + '0';
  return ret;
}
int main() {
#ifdef memset0
  freopen("G.in", "r", stdin);
#endif
  cin.tie(0)->sync_with_stdio(0);
  cin >> T;
  while (T--) {
    sz = 0;
    sz1 = sz2 = 0;
    for (int i = 0; i <= 9; ++i) {
      cin >> s1[i];
      if (s1[i]) rk1[i] = (sz1++);
    }
    for (int i = 0; i <= 9; ++i) {
      cin >> s2[i];
      if (s2[i]) a2[sz2++] = i;
    }
    cin >> str;
    cout << Dec(s2, a2, sz2, Enc(s1, rk1, sz1, str)) << "\n";
  }
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 9ms
memory: 3756kb

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:

2755244567262766742575722
41990991999414091249949
101364364636933104003903
7558888789255872922852552
57222758857875785288225787822
761161760076076167101117776167
6666586555668686566656586856566686658
5611661611611111511116116661611616155
505885888775005550558080707878
912911219633669993999199
885686...

result:

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