我是我的思路,能 AC
#include <iostream> #include <vector>
#include <string> #include <unordered_map> using namespace std; string gameWinner( const string& str ) { unordered_map<char, int> M; for ( char ch : str ) ++M[ch]; // 统计「奇数」字符的个数 int oddChar = 0; for ( auto iter = M.begin(); iter != M.end(); ++iter ) { if ( iter->second % 2 == 1 ) ++oddChar; } if ( oddChar == 0 ) return "Cassidy"; else { if ( oddChar % 2 == 1 ) return "Cassidy"; else { return "Eleanore"; } } } int main() { int n; scanf( "%d", &n ); vector<string> vec( n ); for ( int i = 0; i < n; ++i ) cin >> vec[i]; for ( auto str : vec ) { cout << gameWinner( str ) << endl; } return 0; }