QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#702190#4666. Delete And WinMilkcat2009WA 0ms3592kbC++141.1kb2024-11-02 15:27:472024-11-02 15:27:47

Judging History

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

  • [2024-11-02 15:27:47]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3592kb
  • [2024-11-02 15:27:47]
  • 提交

answer

#include <bits/stdc++.h>
#define REP(i, l, r) for (int i = (l); i <= (r); ++ i)
#define DEP(i, r, l) for (int i = (r); i >= (l); -- i)
#define fi first
#define se second
#define pb emplace_back
#define mems(x, v) memset((x), (v), sizeof(x))
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
using namespace std;
namespace Milkcat {
	typedef long long LL;
	typedef pair<LL, LL> pii;
	const int N = 1e5 + 5;
	int n, m, nx[N][26]; string s, t;
	int main() {
		cin >> s >> t, n = SZ(s), m = SZ(t), s = "#" + s, t = "#" + t;
		REP(i, 0, 25) nx[n][i] = 1e9;
		DEP(i, n - 1, 0) {
			REP(j, 0, 25) nx[i][j] = nx[i + 1][j];
			nx[i][s[i + 1] - 'a'] = i + 1;
		}
		int p = 0, rs = 0;
		REP(i, 0, m - 1) {
			if (i > 0) p = nx[p][t[i] - 'a'];
			if (p > n) break;
			rs = max(rs, i);
			REP(j, 0, t[i + 1] - 'a' - 1)
				rs = max(rs, i + n - nx[p][j] + 1);
		}
		cout << n - rs << '\n';
		return 0;
	}
}
int main() {
	// freopen("string.in", "r", stdin);
	// freopen("string.out", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	int T = 1; cin >> T;
	while (T --) Milkcat::main();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3592kb

input:

pqsrpspqz
pqrpqz

output:


result:

wrong answer Answer contains longer sequence [length = 1], but output contains 0 elements