QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#245937#4666. Delete And Winpbk5418WA 1ms3592kbC++14654b2023-11-10 14:41:522023-11-10 14:41:53

Judging History

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

  • [2023-11-10 14:41:53]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3592kb
  • [2023-11-10 14:41:52]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int sn,tn,ans,now,f[N][26];
char s[N],t[N]; 
int main() {
	scanf("%s%s",s + 1,t + 1); 
	sn = strlen(s + 1),tn = strlen(t + 1);
	for (int i = tn - 1; i >= 0; i --) {
		for (int j = 25; j >= 0; j --) f[i][j] = f[i + 1][j];
		f[i][t[i + 1] - 'a'] = i + 1;
	}
	int sum = 0;
	ans = tn;
	for (int i = 0; i < sn; i ++) {
		for (int j = 0; j < s[i + 1] - 'a'; j ++) if (f[now][j]) ans = min(ans,sum + f[now][j] - now - 1);
		if (!f[now][s[i + 1] - 'a']) break;
		sum += f[now][s[i + 1] - 'a'] - now - 1;
		now = f[now][s[i + 1] - 'a'];
	}
	printf("%d",ans); 
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

pqsrpspqz
pqrpqz

output:

0

result:

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