跳到正文

题解

B3759 唐氏题解

ikunTLE约 2 分钟
原文
文章信息与版本

文章信息

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

版本

  1. v1当前

唐氏传送门

唐氏板子

本题为唐氏题目,可以将判断条件填入下方 Here 处进行判断。

C++
#include<bits/stdc++.h>
using namespace std;
bool solve(){
	int n;cin>>n;
	while(n--){
		string s;cin>>s;
		if(/*Here*/){
			while(n--)
				cin>>s;
			return false;
		}
	}
	return true;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr),cout.tie(nullptr);
	int T;cin>>T;
	while(T--)
		cout<<(solve()?"Pinyin\n":"English\n");
	return 0;
}

唐氏解法 1

由于文本都来自真实、易于人类阅读的文本,所以英语中必定存在大量的 th,故 Here 处填写 s.find("th")!=string::npos。

唐氏解法 2

由于拼音的最大长度为 66,所以若存在某个单词的长度大于 66,那么它一定是英语,故 Here 处填写 s.size()>6。

唐氏解法 3

已知英语单词的末尾基本可以是任何字母,所以在一个字符串 fd 中随便敲几个不可以出现在拼音末尾的字符,则 Here 处填写 fd.find(s.back())!=string::npos。

原文