QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#245920#4666. Delete And Winsherman2023WA 1ms3788kbC++14800b2023-11-10 14:39:182023-11-10 14:39:18

Judging History

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

  • [2023-11-10 14:39:18]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3788kb
  • [2023-11-10 14:39:18]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

const int N = 100000 + 5;

int n, m, cnt = 0;
char s[N], t[N], tmp[N];

int main() {
//	freopen("string.in", "r", stdin);
//	freopen("string.out", "w", stdout);
	
	scanf("%s", s + 1);
	scanf("%s", t + 1);
	
	n = strlen(s + 1), m = strlen(t + 1);
	
	int i = 1, j = 1, ans = 0;
	while(i <= n && j <= m) {
		int isok = 1;
		while(i <= n && j <= m && s[i] == t[j]) {
			tmp[++ cnt] = s[i];
			if(tmp[cnt - 1] > tmp[cnt]) {
				ans ++, isok = 0;
				break;
			}
			i ++, j ++;
		}
		
		if(!isok) break;
		
		if(i > n) {
			ans += m - j + 2;
			break;
		}
		
		if(j > m) break;
		
		if(t[j] < s[i]) break;
		
		ans ++;
		if(tmp[cnt] > t[j]) {
			break;
		}else j ++;
	}
	
	printf("%d\n", ans);
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

pqsrpspqz
pqrpqz

output:

0

result:

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