QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#246485#4666. Delete And WinLCX756WA 0ms3960kbC++201.3kb2023-11-10 21:00:322023-11-10 21:00:33

Judging History

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

  • [2023-11-10 21:00:33]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3960kb
  • [2023-11-10 21:00:32]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
#define fir first
#define sec second
#ifdef LCX
#define msg(args...) void(fprintf(stderr, args))
#else
#define msg(...) void()
#endif

const int maxn = 1e5 + 10, C = 26, inf = 1e9;
int n, m, nxt[maxn][C];
char s[maxn], t[maxn];

int main() {
	// freopen("string.in", "r", stdin), freopen("string.out", "w", stdout);
	scanf("%s%s", s + 1, t + 1);
	n = strlen(s + 1), m = strlen(t + 1);
	for (int i = m + 1; i >= 0; --i) {
		for (int j = 0; j < C; ++j) {
			if (i == m + 1) nxt[i][j] = m + 1;
			else if (i < m && t[i + 1] == j + 'a') nxt[i][j] = i + 1;
			else nxt[i][j] = nxt[i + 1][j];
		}
	}
	int ans = inf, p = 0, cnt = 0;
	for (int i = 1; i <= n; ++i) {
		ans = min(ans, cnt + m - p);
		for (int c = 0; c < s[i] - 'a'; ++c)
			ans = min(ans, cnt + nxt[p][c] - p - 1);
		int np = nxt[p][s[i] - 'a'];
		cnt += np - p - 1, p = np;
		if (p > m) { ans = min(ans, cnt); break; }
	}
	printf("%d\n", ans);
	return 0;
}
/*
pqsrpspqz
pqrpqz

0
*/

/*
whqwillsingatninem
dajiabujianbusan

0
*/

/*
ahhhhhhhhhhhhhhflowerletterishuahua
heisanoierinhighschoolaffiliatedtorenminuniversityofchina

7
*/

詳細信息

Test #1:

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

input:

pqsrpspqz
pqrpqz

output:

0

result:

wrong answer 1st numbers differ - expected: '2', found: '0'