QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#457267 | #8769. Champernowne Substring | ucup-team3678 | WA | 36ms | 4080kb | C++14 | 1.8kb | 2024-06-29 09:51:15 | 2024-06-29 09:51:16 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
signed main() {
int Te; scanf("%d", &Te);
string I;
for (int i = 1; i <= 110; ++i) I += to_string(i);
while (Te--) {
string S; cin >> S;
__uint128_t res = -1;
for (__uint128_t i = 0; i + S.size() < I.size(); ++i) {
int flg = 1;
for (int j = 0; flg && j < S.size(); flg &= (S[j] == '?' || S[j] == I[j + i]), ++j);
if (flg) res = min(res, i + 1);
}
for (int L = 3; L <= S.size() + 1; ++L)
for (int o = 1; o <= L; ++o)
for (int p = 0; p < 10; ++p)
for (int q = 0; q < L; ++q) {
vector<int> T(L, -1); T.back() = p;
for (int i = 2; i <= q + 1; ++i) T.end()[-i] = 9;
int flg = 1;
for (int i = 0, x = 0, y = o; i < S.size() && flg; ++i, --y) {
if (!y) ++x, y = L + (p + x >= 10 && q + 1 == L);
if (S[i] == '?') continue;
int v = S[i] - '0';
if (y == 1) v = (v - x + 10) % 10;
else if (p + x >= 10 && y <= q + 2) v = (v + 9) % 10;
if (y > L) flg &= (!v);
else if (~T.end()[-y] && T.end()[-y] != v) flg = 0;
else T.end()[-y] = v;
}
if (!flg || T[0] == '0' || (q + 1 != L && T.end()[-(q + 2)] == '9')) continue;
for (int i = 0; i < L; ++i) if (T[i] == -1) T[i] = !i;
__uint128_t S = L;
for (__uint128_t i = 1, t = 9; i < L; ++i, t *= 10) S += i * t;
for (__uint128_t i = L - 1, t = 1; ~i; --i, t *= 10) S += L * (T[i] - !i) * t;
res = min(res, S - o + 1);
}
printf("%d\n", (int)(res % 998244353));
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 7ms
memory: 3820kb
input:
9 0 ???1 121 1?1?1 ??5?54?50?5?505?65?5 000000000000 ?2222222 ?3????????9??8???????1??0 9?9??0????????????2
output:
11 7 14 10 314159 796889014 7777 8058869 38886
result:
ok 9 lines
Test #2:
score: -100
Wrong Answer
time: 36ms
memory: 4080kb
input:
10 0000000000000000000000000 0000000?002100000000000?0 6999?999?999999989?999999 0???0?1000?0??000?????0?1 9??9?999998?9?999999100?0 96?9997999?8999991????010 99?99??999999999??????99? ?0?0000?00000000?0210?0?0 99?999?999?99?9??999?9?9? 9?????9?99?99??9??99??9??
output:
545305036 474521705 788888865 5889591 788888870 488873 68888876 723841122 68888820 5882870
result:
wrong answer 2nd lines differ - expected: '574985081', found: '474521705'