QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#201591 | #7332. Dissertation | kjhhjki | WA | 0ms | 61020kb | C++14 | 1.4kb | 2023-10-05 15:20:24 | 2023-10-05 15:20:25 |
Judging History
answer
#include <bits/stdc++.h>
#define MAXN 100005
#define MAXS 1000006
#define MAXT 1003
#define For(I,A,B) for(int I = (A), endi = (B); I <= endi; ++I)
#define foR(I,A,B) for(int I = (A), endi = (B); I >= endi; --I)
#define ForE(I,A) for(int I = head[A]; I; I = e[I].nxt)
using namespace std;
typedef long long _ll;
typedef unsigned int ui;
const int INF = 0x7fffffff;
int T,n,m,sn,sm,ans,pos,dp[MAXT][MAXT],nxt[27][MAXS];
char ss[MAXS],tt[MAXT], *s = ss-1, *t = tt-1;
void solve()
{
cin >> ss >> tt; ans = 0;
n = strlen(ss); m = strlen(tt);
sn += n; sm += m;
if((!n) || !m) { cout << 0 << '\n'; return; }
For(i,0,n) fill(nxt[i],nxt[i]+26,0);
For(i,1,m) fill(dp[i],dp[i]+m+1,INF);
foR(i,n,1)
{
For(j,0,25) nxt[j][i-1] = nxt[j][i];
nxt[s[i]-'a'][i-1] = i;
}
For(i,0,m-1) For(j,0,m-1)
{
if(dp[i][j] == INF) continue;
dp[i][j+1] = min(dp[i][j], dp[i][j+1]);
if(nxt[t[j+1]-'a'][dp[i][j]])
dp[i+1][j+1] = min(dp[i+1][j+1],nxt[t[j+1]-'a'][dp[i][j]]), ans = max(ans,i+1);
}
cout << ans << '\n';
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin >> T;
while(T--)
{
solve();
if(sn == 1000000 || sm == 1000) break;
}
if(T > 0) while(T--) cout << 0 << '\n';
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 61020kb
input:
1 abcdefghijklmnopqrstuvwxyz bbddee
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 22192kb
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:
4 2 5 4 4 5 4 5 5 4 5 5 5 4 4 3 4 4 5 4 5 5 5 4 4 5 3 3 5 4 4 3 3 5 4 5 4 5 3 2 5 4 3 4 4 5 5 5 5 5 3 4 5 4 4 4 4 5 5 4 5 4 5 5 4 4 5 4 4 4 4 4 5 5 4 5 4 5 5 5 5 5 4 5 4 5 5 5 3 4 4 5 4 1 5 3 3 4 3 5 3 4 4 3 4 3 4 5 5 5 4 5 4 3 4 4 3 3 4 5 4 5 4 5 4 4 5 4 3 5 5 3 5 5 4 5 4 5 4 3 4 4 4 4 4 4 5 5 5 5 ...
result:
wrong answer 201st numbers differ - expected: '5', found: '0'