/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 532.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
Contest
Beta Round #1
Language
C++17 (G++ 13.2.0)
Submit At
2023-11-29 16:05:01
Judged At
2024-10-03 14:11:20
Judged By
Score
100
Total Time
2ms
Peak Memory
532.0 KiB