跳到正文

题解

P14317 「ALFR Round 11」A 浴眼盯真 (dingzhen)题解

#SUSPENDED#约 3 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2025年12月12日
篇幅
约 3 分钟
题目
P14317

版本

  1. v1当前

这是本蒟蒻的第一篇题解 ~~~~

由题意知 满足

这个字符串含有 26 个不同的小写字母。

这个字符串中有它的子串(不含这个字符串本身)同样满足浴眼盯真的第 1 个条件。

就是浴眼盯真。

我们需要求这个字符串是不是浴眼盯真。

这里我的思路是只要求出这个字符串长度-1长度的字符串,再求出它所含的小写字母个数。


比如“pqazwsxedcrfvtgbyhnujmikolp”这个字符串 我们可以求出“pqazwsxedcrfvtgbyhnujmikol”这个字串的小写字母个数是26个,所以它满足第二条。

同理如果“qazwsxedcrfvtgbyhnujmikolp”满足条件也可以满足第二条。


所以我们可以用几个函数来实现。

附上代码:

C++
#include<bits/stdc++.h>
using namespace std;
string s;
int siz1() { //s这个字符串前半部分所含小写字母的个数
	int a[26]= {};
	for(int i=0; i<s.size()-1; i++) { //从0到s.size()-1
		if(s[i]<='z'&&s[i]>='a') {
			a[s[i]-'a']++;
		}
	}
	int sum=0;
	for(int i=0; i<26; i++) {
		if(a[i]!=0)sum++;
	}
	return sum;
}
int siz2() { //s这个字符串后半部分所含小写字母的个数
	int a[26]= {};
	for(int i=1; i<s.size(); i++) { //从1到s.size()
		if(s[i]<='z'&&s[i]>='a') {
			a[s[i]-'a']++;
		}
	}
	int sum=0;
	for(int i=0; i<26; i++) {
		if(a[i]!=0)sum++;
	}
	return sum;
}
int siz3() { ////s这个字符串所含小写字母的个数
	int a[26]= {};
	for(int i=0; i<s.size(); i++) {
		if(s[i]<='z'&&s[i]>='a') {
			a[s[i]-'a']++;
		}
	}
	int sum=0;
	for(int i=0; i<26; i++) {
		if(a[i]!=0)sum++;
	}
	return sum;
}
void f() {
	if((siz1()==26||siz2()==26)&&siz3()==26) {
		cout<<"Yes"<<endl;
		return;
	} else if(siz3()==26) {
		cout<<"No"<<endl<<"2"<<endl;
		return;
	} else cout<<"No"<<endl<<"1 2"<<endl;
	return;

}
int main() {
	int t;
	cin>>t;
	while(t--) {
		cin>>s;
		if(s.size()<26) {
			cout<<"No"<<endl<<1<<" "<<2<<endl;
			continue;
		}
		f();
	}
	return 0;
}
原文