萌新求助在线卡常
查看原帖
萌新求助在线卡常
728483
wwwidk1234楼主2023/9/20 22:34

超时了 10∼50 ms10\sim 50\:\mathrm{ms},求卡常

https://www.luogu.com.cn/record/125260000

https://www.luogu.com.cn/record/125259837

#include<bits/stdc++.h>
//#define int long long
#define debug(x) cout<<#x<<"="<<x<<endl;

using namespace std;
vector<string> res;

inline bool check(string psw)
{
	if(psw.length()<6||psw.length()>12) return false;
	bool upper=false,lower=false,num=false;
	bool special=false;
	for(char ch:psw)
	{
		if(!isdigit(ch)&&!isalpha(ch)&&ch!='!'&&ch!='@'&&ch!='#'&&ch!='$') return false;
		if(isupper(ch)) upper=true;
		else if(islower(ch)) lower=true;
		else if(isdigit(ch)) num=true;
		else if(ch=='!'||ch=='@'||ch=='#'||ch=='$') special=true;
	}
	if(upper+lower+num>=2 && special) return true;
	else return false;
}
signed main()
{
	string s;
	for(char c=getchar();c!='\n';c=getchar())
	{
		if(c==',') res.push_back(s),s.clear();   //O(1)
		else s.push_back(c);   //O(1)
	}
	res.push_back(s);
	for(auto i:res) if(check(i)) cout<<i<<"\n";
	return 0;
}
2023/9/20 22:34
加载中...