萌新求助在线卡常

B3843 [GESP202306 三级] 密码合规

wwwidk1234 @ 2023-09-20 22:34:46

超时了 10\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;
}

by Rakuteni @ 2023-09-20 22:37:42

快读快写?


by wwwidk1234 @ 2023-09-20 22:40:08

@Rakuteni string快读快写还不知道咋用


by wwwidk1234 @ 2023-09-20 22:58:53

已自己解决,输入写挂了


|