QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#703681 | #5981. Costly Binary Search | Nelofus | 0 | 680ms | 20392kb | C++20 | 1.3kb | 2024-11-02 18:12:19 | 2024-11-02 18:12:19 |
Judging History
answer
// Code by Heratino & Nelofus
// 泣いていたって空は晴れるよ
#include <bits/stdc++.h>
using i64 = long long;
//{{{
template<typename Ta, typename Tb>
inline void chkmax(Ta &a, const Tb &b) {if (a < b) a = b;}
template<typename Ta, typename Tb>
inline void chkmin(Ta &a, const Tb &b) {if (a > b) a = b;}
//}}}
constexpr int N = 1e6 + 10;
constexpr int M = 310;
int f[N][M], c[N];
int lst[N][10];
int n;
std::string s;
int main() {
#ifdef HeratinoNelofus
freopen("input.txt", "r", stdin);
#endif
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int T;
std::cin >> T;
for (int _ = 1; _ <= T; _++) {
std::cin >> s;
n = s.length();
s = ' ' + s;
for (int i = 1; i <= n; i++)
c[i] = s[i] - '0';
for (int i = 1; i <= n; i++)
memcpy(lst[i], lst[i - 1], sizeof(lst[i])), lst[i][c[i]] = i;
for (int i = 0; i < M; i++)
f[n][i] = n + 1;
for (int l = n - 1; l >= 0; l--) {
f[l][0] = l + 1;
for (int v = 1; v < M; v++) {
f[l][v] = f[l][v - 1];
for (int cx = 1; cx <= 9 && cx <= v; cx++) {
int p = f[l][v - cx];
int q = lst[p][cx];
if (q < l) continue;
chkmax(f[l][v], f[q][v - cx]);
}
}
}
for (int i = 0; i < M; i++)
if (f[0][i] == n + 1) {
std::cout << "Case #" << _ << ": " << i << '\n';
break;
}
}
return 0;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 680ms
memory: 20392kb
input:
50 8 5128831164925953487661279378526736416489768154389124821528467927357884749642747626797857463132866343496157991453139582295398452863172464853698678624523849653538713928372648295734165346972222781179687541337591976277864785653638476127839556323849395641196246971351933655287441377531627938395427487...
output:
Case #1: 8 Case #2: 37 Case #4: 37 Case #5: 34 Case #6: 114 Case #7: 126 Case #8: 24 Case #9: 37 Case #10: 103 Case #14: 117 Case #17: 14 Case #22: 39 Case #23: 14 Case #24: 9 Case #25: 80 Case #26: 37 Case #27: 126 Case #35: 117 Case #38: 1 Case #39: 3 Case #41: 30 Case #42: 37 Case #45: 126 Case #...
result:
wrong answer 3rd lines differ - expected: 'Case #3: 34', found: 'Case #4: 37'
Subtask #2:
score: 0
Time Limit Exceeded
Test #2:
score: 0
Time Limit Exceeded
input:
50 647322722753778843259213887674615134214258235986992692879314555957455541351526284343217116351733247781713552149464672262787737941588358671583528664757823365936975517145283412965139791726299864122725212222496898855627124979178341548651669956711341742838725446489235961853391195148929571712449139335...