QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#608130 | #7332. Dissertation | _Sherbiny | WA | 340ms | 113908kb | C++14 | 1.2kb | 2024-10-03 18:57:20 | 2024-10-03 18:57:20 |
Judging History
answer
// Author: _Sherbiny
#include "bits/stdc++.h"
#ifdef DBG
#include "./debug.h"
#else
#define dbg(...)
#endif
using namespace std;
typedef long long ll;
#define endl '\n'
///////////////////////////////////
const int oo = 2e9, N = 1001;
vector<array<int, 26>> nxt;
string a, b;
int n, m;
int dp[N][N], vis[N][N], id = 0;
int go(int i, int rem) {
if (!rem) return 0;
if (i < 0) return n;
int &res = dp[i][rem];
if (vis[i][rem] == id) return res;
vis[i][rem] = id;
res = go(i - 1, rem);
int ind = go(i - 1, rem - 1);
ind = nxt[ind + 1][b[i] - 'a'];
return res = min(ind, res);
}
void magic() {
++id;
cin >> a >> b;
n = a.size(), m = b.size();
nxt.assign(n + 2, {});
nxt[n].fill(n);
nxt[n + 1].fill(n);
for (int i = n - 1; i >= 0; --i) {
nxt[i] = nxt[i + 1];
nxt[i][a[i] - 'a'] = i;
}
for (int sz = m; sz >= 0; --sz) {
if (go(m - 1, sz) < n) {
cout << sz;
return;
}
}
}
signed main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int t = 1;
cin >> t;
while (t--) magic();
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 5696kb
input:
1 abcdefghijklmnopqrstuvwxyz bbddee
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: -100
Wrong Answer
time: 340ms
memory: 113908kb
input:
4106 ababbbab babaa aabaaaaa bbbab aababaab bbaab aababbba aaaaa aabbabbb baabb aabababb abbbb aabbabab babaa aaabbaaa aaabb aaababba ababb aabbbaba abaaa abbbaaba bbbab aaaababb aabab abbbaaba abbba abbbabbb bbbaa aaabaaaa aaabb abbababb baaaa aaaababb babbb abaaaaab aabaa ababaaab aabaa abbbabaa b...
output:
425345445455443344444554453354433545453253334444443454444554444534544444544435455545455434454143333434434335544442443335354544443453444445434444345444254434344444444434544454345454443444432433343454434424445444355443552444345454434144424539854344334555455253554434443434425445353454344345443443542253...
result:
wrong output format Expected integer, but "425345445455443344444554453354...3424444244445543455445444524354" found