This code is for the problem PASSWD .
Can anybody tell me why my code is wrong,I am suspecting that the mistake I made is I allowed the first and the last character to be a character from A to Z, but the statement allowed so, that is there was no restriction on the first or the last letter being an uppercase letter.
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define INF INT_MAX
#define MAXN 100005
#define debug(x) std::cerr<<x<<endl;
#define FAST ios_base::sync_with_stdio(false);
//for fastening the programme
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization("unroll-loops")
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve(){
string s;cin>>s;
int n=s.length();
if(n<10){
cout<<"NO"<<endl;
return;
}else{
char symbols[]={ '@', '#', '%', '&', '?'};
if((s[0]>='a' && s[0]<='z') || (s[0]>='A' && s[0]<='Z')){
if((s[n-1]<='z' && s[n-1]>='a') || (s[n-1]<='Z' && s[n-1]>='A')){
bool ok=false;
for(int i=0;i<5;i++){
for(int j=1;j<=n-2;j++){
if(s[j] == symbols[i]){
ok=true;
break;
}
}
if(ok)
break;
}
if(!ok){
cout<<"NO"<<endl;
return;
}else{
ok=false;
for(int i=1;i<=n-2;i++){
if( (s[i]>='0') && (s[i]<='9')){
ok=true;
break;
}
}
if(!ok){
cout<<"NO"<<endl;
return;
}else{
ok=false;
for(int i=1;i<=n-2;i++){
if(s[i] >='A' && s[i]<='Z'){
ok=true;
break;
}
}
if(!ok){
cout<<"NO"<<endl; // some "A" or "B" inside the string.
return;
}else{
ok=false;
for(int i=0;i<n;i++){
if(s[i]>='a' && s[i]<='z'){
ok=true;
cout<<"YES"<<endl;
return;
}
}
cout<<"NO"<<endl;
return;
}
}
}
}else{
cout<<"NO"<<endl;
return;
}
}else{
cout<<"NO"<<endl;
return;
}
}
}
int main() {
FAST;
// #ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// #endif
int tt;cin>>tt;
while(tt--){
solve();
}
}