标签:div string def == efi memset i++ max pac
#include <bits/stdc++.h> #define mem(a, b) memset(a, b, sizeof(a)) using namespace std; const int maxn = 100100, INF = 0x7fffffff; string str; int vis[26]; int main() { cin>> str; mem(vis, 0); int cnt = 0, ans = 0; for(int i=0; i<str.size(); i++) vis[str[i] - ‘a‘]++; for(int i=0; i<26; i++) if(vis[i]) { cnt++; if(vis[i] >= 2) ans++; if(cnt > 4) { cout<< "No" <<endl; return 0; } } if(cnt == 1) { cout<< "No" <<endl; } else if(cnt == 2) { if(ans == 2) cout<< "Yes" <<endl; else cout<< "No" <<endl; } else if(cnt == 3) { if(ans) cout<< "Yes" <<endl; else cout<< "No" <<endl; } else if(cnt == 4) cout<< "Yes" <<endl; return 0; }
CodeForces - 955B(用char会超时。。。)
标签:div string def == efi memset i++ max pac
原文地址:https://www.cnblogs.com/WTSRUVF/p/9414227.html