社区讨论

求助!!此代码为什么 RE(只要告诉我为什么RE就好啦)

学术版参与者 2已保存回复 1

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
1 条
当前快照
1 份
快照标识符
@mi7yocb0
此快照首次捕获于
2025/11/21 05:46
4 个月前
此快照最后确认于
2025/11/21 05:46
4 个月前
查看原帖
样例格式
3
abcde
ace
abcde
aed
abcde
abcd
CPP
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6+5;
char s[N], t[N];

int main(){
	int T;
	cin >> T;
	while(T--){
		memset(s,'\0',sizeof(s));
		memset(t,'\0',sizeof(t));
		cin >> s; cin >> t;
		int ls = strlen(s), lt = strlen(t);
		if(lt != ls-2){
			if(!T){
				cout << 0;
			} else cout << 0 << endl;
			continue;
		}
		int j = 0, cnt = 0;
		for(int i = 0; i < ls; i++){
			while(s[i] != t[j])
				i++, cnt++;
			if(cnt >= 2){
				break;
			}
			j++;
		}
		if(cnt != 2){
			if(!T){
				cout << 0;
			} else cout << 0 << endl;
			continue;
		} else {
			if(!T){
				cout << 1;
			} else cout << 1 << endl;
			continue;
		}
	}
	return 0;
}

回复

1 条回复,欢迎继续交流。

正在加载回复...