QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#687163#6466. ConcertsPetroTarnavskyi#ML 7ms44544kbC++231.0kb2024-10-29 17:29:322024-10-29 17:29:33

Judging History

你现在查看的是最新测评结果

  • [2024-10-29 17:29:33]
  • 评测
  • 测评结果:ML
  • 用时:7ms
  • 内存:44544kb
  • [2024-10-29 17:29:32]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#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--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef double db;

const int N = 2e5 + 47;
const int K = 1e3 + 47;
const int mod = 1e9 + 7;

void updAdd(int& a, int b)
{
	a += b;
	if(a >= mod)
		a -= mod;
}


int dp[N][K];



int main()
{
	ios::sync_with_stdio(0); 
	cin.tie(0);
	
	LL k, n;
	cin >> k >> n;
	
	
	VL h(26);
	FOR(i, 0, 26)
		cin >> h[i];
	
	string s, t;
	cin >> s >> t;
	
	
	dp[0][0] = 1;
	FOR(i, 0, n)
	{
		FOR(j, 0, k + 1)
		{
			if(j != k && t[i] == s[j])
				updAdd(dp[min(n, i + 1 + h[t[i] - 'A'])][j + 1], dp[i][j]);
			updAdd(dp[i + 1][j], dp[i][j]);
		}
	}
	cout << dp[n][k] << "\n";
	
	
	
	

	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 7884kb

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: 3ms
memory: 24012kb

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: 7ms
memory: 44544kb

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: -100
Memory Limit Exceeded

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: