求助,看一下午加一晚上了,在其他网站AC了,但是在洛谷过不了

B3843 [GESP202306 三级] 密码合规

ouyangxiu @ 2024-08-30 20:29:24

define _CRT_SECURE_NO_WARNINGS

include<stdio.h>

include<iostream>

include<vector>

include<math.h>

include<string>

include<sstream>

using namespace std;

int main() { int s1 = 0, s2 = 0, s3 = 0, s4 = 0, ss = 0; vector<string> a; string n; string m; getline(cin, m); stringstream sm(m); while (getline(sm, n, ',')) { a.push_back(n); }

int size = a.size();
for (int i = 0; i < size; i++)
{
    //cout << "safe" << endl;
 s1 = 0, s2 = 0, s3 = 0,s4=0, ss = 0;
    if (a[i].size() > 12 || a[i].size() < 6)a.erase(a.begin() + i), size--, i--, ss = 1;

    else
    {
        for (int i2 = 0; i2 < a[i].size(); i2++)
        {
            if (a[i][i2] >= 'a' && a[i][i2] <= 'z') s1 = 1;
            else if (a[i][i2] >= 'A' && a[i][i2] <= 'Z')s2 = 1;
            else if (a[i][i2] >= '1' && a[i][i2] <= '9')s3 = 1;
            else if (a[i][i2] == '!' || a[i][i2] == '#' || a[i][i2] == '@' || a[i][i2] == '$')s4 = 1;
            else
            {

                //cout <<"case:"<<i2 << " dele2:" << a[i] << endl;
                a.erase(a.begin() + i), ss = 1, size--, i--;
                break;

            }
        }
        if (ss != 1)
        {
            if((s1 + s2 + s3) < 2 || s4 == 0)  a.erase(a.begin() + i), size--, i--;
        }
    }
}

for (int i = 0; i < a.size(); i++)
{
    cout << a[i];
    if (i != a.size() - 1)cout << endl;
}

}```

define _CRT_SECURE_NO_WARNINGS

include<stdio.h>

include<iostream>

include<vector>

include<math.h>

include<string>

include<sstream>

using namespace std;

int main() { int s1 = 0, s2 = 0, s3 = 0, s4 = 0, ss = 0; vector<string> a; string n; string m; getline(cin, m); stringstream sm(m); while (getline(sm, n, ',')) { a.push_back(n); }

int size = a.size();
for (int i = 0; i < size; i++)
{
    //cout << "safe" << endl;
 s1 = 0, s2 = 0, s3 = 0,s4=0, ss = 0;
    if (a[i].size() > 12 || a[i].size() < 6)a.erase(a.begin() + i), size--, i--, ss = 1;

    else
    {
        for (int i2 = 0; i2 < a[i].size(); i2++)
        {
            if (a[i][i2] >= 'a' && a[i][i2] <= 'z') s1 = 1;
            else if (a[i][i2] >= 'A' && a[i][i2] <= 'Z')s2 = 1;
            else if (a[i][i2] >= '1' && a[i][i2] <= '9')s3 = 1;
            else if (a[i][i2] == '!' || a[i][i2] == '#' || a[i][i2] == '@' || a[i][i2] == '$')s4 = 1;
            else
            {

                //cout <<"case:"<<i2 << " dele2:" << a[i] << endl;
                a.erase(a.begin() + i), ss = 1, size--, i--;
                break;

            }
        }
        if (ss != 1)
        {
            if((s1 + s2 + s3) < 2 || s4 == 0)  a.erase(a.begin() + i), size--, i--;
        }
    }
}

for (int i = 0; i < a.size(); i++)
{
    cout << a[i];
    if (i != a.size() - 1)cout << endl;
}

}


|