QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#201601 | #7332. Dissertation | kjhhjki | RE | 0ms | 60780kb | C++14 | 1.2kb | 2023-10-05 15:24:54 | 2023-10-05 15:24:54 |
Judging History
answer
#include <bits/stdc++.h>
#define MAXN 100005
#define MAXS 1000006
#define MAXT 3003
#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,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);
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();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 60780kb
input:
1 abcdefghijklmnopqrstuvwxyz bbddee
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: -100
Runtime Error
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...