QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#246518#4666. Delete And WinatgcWA 1ms3416kbC++14910b2023-11-10 21:37:542023-11-10 21:37:55

Judging History

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

  • [2023-11-10 21:37:55]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3416kb
  • [2023-11-10 21:37:54]
  • 提交

answer

/*YYC is Thinking Here*/
#include<bits/stdc++.h>
#define mids(l,r) const auto mid = (l + r) >> 1
#define lb(x) (x&-x)
#define ls (x<<1)
#define rs (ls|1)
#define int long long
#define pii pair<int,int>
#define inf 0x3f3f3f3f3f3f3f3f
using namespace std;
const int maxn = 2e5+10;

char s[maxn],t[maxn];
int n,m;

int nxt[maxn][26];
int ans = 0;

signed main() {
	ios::sync_with_stdio(0),cin.tie(0);
	cin>>(s+1)>>(t+1);
	n = strlen(s+1), m = strlen(t+1);
	for(int i = 0;i < 26;++i) nxt[m+1][i] = m+1;
	for(int i = m;i;--i) {
		memcpy(nxt[i],nxt[i+1],sizeof nxt[0]);
		nxt[i][t[i]-'a'] = i;
	}
	int p = 1;
	for(int i = 1;i <= n;++i) {
		int g = m+1;
		for(int c = 0;c < s[i]-'a';++c) g = min(g,nxt[p][c]);
		// deb(p,i,g);
		ans = max(ans,i + m - g);
		p = nxt[p][s[i]-'a']+1;
		if(p >= m+1) break;
	}
	cout<< m - ans;
}

/*
* I love it all
* Go forward,move forward !
*/

详细

Test #1:

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

input:

pqsrpspqz
pqrpqz

output:

0

result:

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