QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#96612 | #2922. Word Puzzle | zezoo050 | AC ✓ | 8076ms | 46108kb | C++20 | 1.1kb | 2023-04-14 19:47:14 | 2023-04-14 19:47:18 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
string s, t;
int id;
const int m = 1e9 + 7;
int add(int x, int y)
{
return (1ll * x + y) % m;
}
const int N = 1e5 + 5;
int dp[N][51], vis[N][51];
int solve(int i, int j)
{
if (j == t.size())
return 1;
if (i == s.size())
return 0;
if (vis[i][j] == id)
return dp[i][j];
vis[i][j] = id;
dp[i][j] = 0;
if (s[i] == t[j])
dp[i][j] = add(dp[i][j], solve(i + 1, j + 1));
return dp[i][j] = add(dp[i][j], solve(i + 1, j));
}
void tc()
{
cin >> s;
cin >> t;
set<string> st;
string temp;
for (int i = 0; i < t.size(); i++)
{
string cur;
for (int j = i; j < t.size(); j++)
cur += t[j];
cur += temp;
st.insert(cur);
temp += t[i];
}
int ans = 0;
for (auto ss : st)
{
t = ss;
id++;
ans = add(ans, solve(0, 0));
}
cout << ans << '\n';
}
int main()
{
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int t = 1;
// cin >> t;
while (t--)
{
tc();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5376kb
input:
x x
output:
1
result:
ok single line: '1'
Test #2:
score: 0
Accepted
time: 2ms
memory: 5408kb
input:
x y
output:
0
result:
ok single line: '0'
Test #3:
score: 0
Accepted
time: 2ms
memory: 5328kb
input:
aaaaaa aaa
output:
20
result:
ok single line: '20'
Test #4:
score: 0
Accepted
time: 2ms
memory: 5456kb
input:
ababababab abab
output:
50
result:
ok single line: '50'
Test #5:
score: 0
Accepted
time: 1ms
memory: 5372kb
input:
ababababab abbba
output:
25
result:
ok single line: '25'
Test #6:
score: 0
Accepted
time: 1ms
memory: 5336kb
input:
abcdefg cdefgab
output:
1
result:
ok single line: '1'
Test #7:
score: 0
Accepted
time: 182ms
memory: 46000kb
input:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
output:
272473072
result:
ok single line: '272473072'
Test #8:
score: 0
Accepted
time: 8076ms
memory: 46104kb
input:
bbbabaaabbbbaabbbbaaabbaaabbbbaaabaababaabaaaaaabbbaabaabbbaababbbabbbbbbbabbaabbabbabbabaaaabbbaabbabbaaabbbbabababaabbabababaabaaabbaabaaaababbabbababaabbabbaaabbaabbbbbaaabaabababbbbbaaabbaaaaaabaabababbabbaaaabaabbbaaaababbabababbaabababbaabbbbaababaabbaaabaabaababababbaaaababbbbababbbbaabbbabab...
output:
282848711
result:
ok single line: '282848711'
Test #9:
score: 0
Accepted
time: 3ms
memory: 5472kb
input:
baabaabbbbbaabbbabaaaaabaaaaabaaabaabbaabaaabbaababbabbaaaabbabbabbaaaabbbabbbbbbaaabbaaababbbbaabba babaaabaaaaabaaabaabababbabbbbaaaabbabaabbb
output:
420104829
result:
ok single line: '420104829'
Test #10:
score: 0
Accepted
time: 3ms
memory: 5400kb
input:
abbbababcccbbaacacccacabaacaaaccbcabaaaaababcbabbcbbcacabababababccbccaacccabaccccabcaabababbacccccb babbbaabbabcacabaccccabcababababcccbaacbaacbcbaaaa
output:
766520634
result:
ok single line: '766520634'
Test #11:
score: 0
Accepted
time: 2ms
memory: 5364kb
input:
cecbcaacdeeeddbdcbeeebecdddcbdeeebcabcabcccebeddeaceeadeceaeadedacbccbddddbedddbcbcbdecbcbcdaebcedee caaed
output:
47423
result:
ok single line: '47423'
Test #12:
score: 0
Accepted
time: 6720ms
memory: 46052kb
input:
babbbbbabbbbbbbaaabaabaabbbbaabbbbaaaaabbaaabaabbbbaaaababbbaaabbbbbbabaaabbbaaabbbababbaaabbaaabaaaaaaaaababbbbbabbaaabbbabbaabbaaabbabbbaabbbaaaaaaabaaabaaaaabaaabbaababaabaaabbbaabaaabbbaabbbbaaabaabbabbaabbbbbababbbabbbabbbababbaaaabbababbaababaabababbbaaaabababbbbababbbbbbaabaabbababaaaababaaba...
output:
486637450
result:
ok single line: '486637450'
Test #13:
score: 0
Accepted
time: 6672ms
memory: 46004kb
input:
caaaacaababbaacbbacccbaccbcbabbcaabaacabbaabcbbacbcbbacabbacbaabcbccacacabaaaacaaaabccabaaababaacaacacacacbcacaaaaacbcbaaabcabcbacabacbccaabbbbaccbbbcbabccbacbcbcbbaacbabcbabbbbabbccccbbabaacaabbacabaccacbbcabaabaacbcabbabbbabcccacbcaabbcacaccbaacbbbbacccbccacacabccacbbaccabcacaabcabcbccbcccabacbbac...
output:
936394934
result:
ok single line: '936394934'
Test #14:
score: 0
Accepted
time: 6934ms
memory: 46108kb
input:
dbcdddaaadacdccceadccedbbccbabcebadacaebdabbcecaebbbeeddbadcddbebeccaccebeedeccdcbeebbcbddccbbeabeebdccadabeacbecdbdcbdcbadaccbaabaceaabddabcabeceaccbbdedddaabbbeeeaedbeebcebdaccdcdaddaeeecccccaedaceecabdcbaaaedaecbcedaceedadaeabeddcadbbeabadedbadedadeeaddacccdeacabbbeebcddaaaaddeccaeeccceddbaddbedd...
output:
913565196
result:
ok single line: '913565196'
Test #15:
score: 0
Accepted
time: 395ms
memory: 46012kb
input:
vyupeidnwqivhxkbpswxpzmeuiucitgwiwnmlxwdzjdjahahukhwuvbqrussinpdvnhhgkhfwjrqobseorqztwnlqiuzwnmwwpeyimnrauerxvfgtrjgynvwypqiopphlblpphprkqsuatvujhbdktoqkxiayrarcesuwinubtqbtuyvkfgvewgsajtozaovzbotbljodualzwloalmpbkzpdpklsgbbevjggjkagpdpojjzyaogywifkcozzgjorpkkhovpyqgqnkmvplzncifpxmlmgijjhvhvvfvjjput...
output:
209906227
result:
ok single line: '209906227'
Test #16:
score: 0
Accepted
time: 6687ms
memory: 45984kb
input:
mqjwsxbfvfgmjwgwxagrpurduavgmflksepsgtaiayxurcwvpfgbdfntmxebtwagtvenyjqgmltobdsegwzvarwuomfjzvehbrswxnwblaiybojuotivicvrdqzzzkcmsdbkbwqjsjfdjjclujrbvaqykpodcerjjxlztclrowuwdbnqhrxhgesyyknqoaiusoawhtcmmjacugidjabncvgolnapmdfsetkjswaxxoeavvajsfvrdhwabwsshkoteayjdrnsltjxqufsvawqffizqmrljenpkbuxsejqixao...
output:
214605073
result:
ok single line: '214605073'
Test #17:
score: 0
Accepted
time: 7813ms
memory: 46044kb
input:
akajzzsqdheiuzcfetnlncvavcdugmlwzokhuoonnzakehmazollpnfggivfpdrdxwtdcszyvuoseeunfrjmhukcjhnqzqbbnifkelbhychdecdtiaxpcsbovburhzselpfbxjyecxpgrsbzwvamtnhaprldukdevbfwyqkkdoetivnjorrfvwznuysuyyyoxxwxkrrnupouwrnfkroauahcywbgxjsunlizmsohqmttextvzfswbhdwgzrhprudwnmghkjsnrpyzisjvovsqabtyvqodztmjmgllaacnmbe...
output:
63161148
result:
ok single line: '63161148'
Test #18:
score: 0
Accepted
time: 54ms
memory: 36800kb
input:
abbabbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbababbabbababba...
output:
241224381
result:
ok single line: '241224381'
Test #19:
score: 0
Accepted
time: 4870ms
memory: 38924kb
input:
abbabbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbababbabbababba...
output:
718304672
result:
ok single line: '718304672'
Test #20:
score: 0
Accepted
time: 1ms
memory: 5328kb
input:
programming rgg
output:
2
result:
ok single line: '2'
Test #21:
score: 0
Accepted
time: 2ms
memory: 5444kb
input:
aabbaa aba
output:
12
result:
ok single line: '12'
Test #22:
score: 0
Accepted
time: 2ms
memory: 5436kb
input:
acca acac
output:
0
result:
ok single line: '0'