/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB

Code

    #include <bits/stdc++.h>
    #define ll long long
    #define F first
    #define S second
    #define endl '\n'
    #define Endl '\n'

    using namespace std;

    const int N = 2e5 + 5;
    int tc, n, m, a[N];

    int main() {
        ios_base::sync_with_stdio(0);
        cin.tie(0); // cout.tie(0);
        string specialCharacters = "!@#$%^&*()";
        cin >> tc;
        while (tc--) {
            string password;
            cin >> password;
            bool validLength = true;
            if (password.size() < 8) {
                validLength = false;
            }
            bool hasSpecialCharacter = false, hasUppercase = false, hasLowercase = false, hasDigit = false;
            for (int i = 0; i < password.size(); i++) {
                if (specialCharacters.find(password[i]) != string::npos) {
                    hasSpecialCharacter = true;
                }
                if (isupper(password[i])) {
                    hasUppercase = true;
                }
                if (islower(password[i])) {
                    hasLowercase = true;
                }
                if (isdigit(password[i])) {
                    hasDigit = true;
                }
            }
            bool isValid = validLength && hasSpecialCharacter && hasUppercase && hasLowercase && hasDigit;
            cout << (isValid ? "valid" : "invalid") << endl;
        }

        return 0;
    }

Information

Submit By
Type
Submission
Problem
P1007 Password Checker
Language
C++17 (G++ 13.2.0)
Submit At
2023-12-04 16:37:36
Judged At
2023-12-04 16:37:36
Judged By
Score
100
Total Time
1ms
Peak Memory
540.0 KiB