A题
分析:
直通过STl暴力就可以了(题的本来目的是考察KMP,但数据水到不行)
代码:
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin >> t;
while (t--)
{
int ans = 0;
string m, n, s;
cin >> m >> s;
n = m;
reverse(n.begin(), n.end());
int mlen = m.length(), slen = s.length();
for (int i = 0; i <= slen - mlen; i++)
{
if (s.substr(i, mlen) == m)ans++;
if (s.substr(i, mlen) == n)ans++;
}
if (n == m)ans /= 2;
cout << ans << endl;
}
return 0;
}
C题
分析:
本题不算难,但坑点很多:多组数据,一段序列只可以包含一个密码子。有一处想不到就要wa一发。
代码:
#include<bits/stdc++.h>
using namespace std;
struct In
{
int st;
int len;
}in[510];
int main()
{
int n, k;
while (cin >> n >> k)
{
int alen[110], tlen, cnt = 0;
string a[110], t, s;
for (int i = 0; i<n; i++){
cin