QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#687203 | #6466. Concerts | LaVuna47# | ML | 97ms | 86468kb | C++20 | 1.4kb | 2024-10-29 17:35:46 | 2024-10-29 17:35:46 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define x first
#define y second
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
typedef long long ll;
typedef double db;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<db, db> pdd;
#ifdef ONPC
mt19937 rnd(228);
#endif
#define AL_SZ 26
const ll MOD = 1e9+7;
ll H[AL_SZ];
string S, T;
vector<vector<ll>> dp;
ll f(int i, int j)
{
if(i == sz(S))
return 1;
if(j >= sz(T))
return 0;
if(dp[i][j] != -1)
return dp[i][j];
ll res = 0;
res += f(i, j+1);
if(S[i] == T[j])
{
res += f(i+1, j+1+H[T[j]-'A']);
}
res %= MOD;
return dp[i][j] = res;
}
int solve()
{
ll k, n;
if(!(cin >> n >> k))
return 1;
FOR(i,0,AL_SZ) cin >> H[i];
cin >> S >> T;
dp = vector<vector<ll>>(sz(S)+4, vector<ll>(sz(T)+7, -1));
cout << f(0,0) << '\n';
return 0;
}
int32_t main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int TET = 1e9;
//cin >> TET;
for (int i = 1; i <= TET; i++)
{
if (solve())
break;
#ifdef ONPC
cerr << "_________________________________\n";
#endif
}
#ifdef ONPC
cerr << "\nfinished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec\n";
#endif
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3968kb
input:
20 1000 3 8 6 7 7 2 3 0 9 0 3 6 3 5 2 4 5 5 2 6 7 0 9 5 0 1 JWNOUXSQLCNEPZIATFRG VBNTLXRPBHYNSDNNUDOLFJWPHOZVJWERGFCGRQDSOHPSSYXKBLEHYVXOCZHQPIZFQVFEDZJFQPWJOZXYUNWGOBLGHCGDAWTLNPVOHESQFLSIYYSFBRPLCRAVRGTKGTATWBBMRWWHPIYEKYZJSTLZNJAOENGENYCWJSBTZNSVBTJUWHBVRWJXURHVNJCMBQKDGJPURYCDBKESUGJUULYBQTXBOBN...
output:
324855496
result:
ok single line: '324855496'
Test #2:
score: 0
Accepted
time: 2ms
memory: 7672kb
input:
100 5000 21 12 8 29 4 2 0 10 2 8 25 28 21 18 29 24 25 26 11 7 17 14 11 18 8 25 QACFDQHBWAEVSUJFPGLXRBQYAPUGUQKKPEXDKOGLOQKEIVNCIHYTFNVIMJSJUCHESHVZVGWMJISHNCTNEAKWYUUQAGMFYQPSRHDQ VYXPGLMYGFZYBSPWFWVXCNCGMEGQXJOIKFLJEZAKVTFPYXQLXXUMNKAKAJOEFSIBZYWLXSIAMJIYFAVTLZXHOQOHDCJLVEEWJSEDTHYRUHDZNGGHOKZWMCUR...
output:
32963522
result:
ok single line: '32963522'
Test #3:
score: 0
Accepted
time: 10ms
memory: 16180kb
input:
150 10000 16 47 24 35 25 47 14 24 43 35 32 16 10 2 25 45 34 1 29 1 48 6 26 15 21 42 YNIVUSBGIXCPLSHDOOKOEUHCSGYTEKXPJFWAGMQJZTILXRBAVFNWLWNCGRDFDULGMCKFAPXZOKDXDOKQHMWMTKZLBJRXLDUNWVHQLHZDUMYFXLKWWJRISZPMBTEXUAVXNJMHPHIJTBQJEIISXVFOSO ZBNWNVOGYUDWAAIQYSJGQGQWMJOYBAXUMMQXJCPWBQGGNDVDBEYFEKTNPGRYLUDNR...
output:
975730909
result:
ok single line: '975730909'
Test #4:
score: 0
Accepted
time: 97ms
memory: 86468kb
input:
200 50000 92 55 67 34 6 14 96 73 82 87 45 94 11 18 35 80 14 73 84 32 44 9 95 37 50 42 JYSXZIQYKUUQNNMKUPEZBKYYIQIWRYUTVSECDODULYVDQBPCQYOXUKKHQWQUDVFOEYAECSLQBULKNNVKYPZHCYYRHJOUEYLBWLWEHTZHDVYTCXCXQFYNPUIKOWDZLPLBAPFWPXCUBFPDIPUXISNYEFMATHLIPQKWLEXPLBMDLBPBKFAIJJKTMPZCOPYSGJFZWVPXBWXZ AJDGGTCBQGEMR...
output:
42995752
result:
ok single line: '42995752'
Test #5:
score: -100
Memory Limit Exceeded
input:
250 70000 52 77 78 39 101 105 67 44 120 77 94 79 52 55 39 48 69 15 12 1 123 138 61 64 126 0 MUVQMZFNKVIJOXVUHNYKRENDWZQUWGWDPBIPAVPJZCYZEWCMAJINLQVRKTFZOXFOBZXCLCTBFKQDZXQQZRCVKHYHUHAEHOEHUVJXNOPLIFPHQTEABMROMUJKHXUKWAMSAJRCYYAKNBXRFHSJCGUFZZZZXIKFZIIYIRVDAQJLONKPPDQRQDIHLZJKQBJCUOFAULUILVYKHABQGZDV...
output:
762393745