#include<bits/stdc++.h>
#define endl "\n"
#define int long long
using namespace std;
void slove() {
std::string s;
std::cin >> s;
int cnt0 = 0, cnt1 = 0;
for (auto c : s) {
if (c == '0') cnt0++;
else cnt1++;
}
if (cnt0 % 2 == cnt1 % 2) {
if (cnt1 & 1) {
std::cout << "No" << endl;
} else std::cout << "Yes" << endl;
} else std::cout << "Yes" << endl;
}
signed main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cout.tie(nullptr);
int T = 1;
std::cin >> T;
while (T--) {
slove();
}
return 0;
}
去仔细想一下为什么101可以变为相同的,手玩一下后注意到,我们对长度为2的字串进行交换相当于把某个字符以1的速度进行移动,又因为移动次数不受限制,所以可得出我们可以把我们想要的任意字符放在任意位置。那么贪心肯定是把相同的字符放在一起,那么这题就只跟01字符的数量有关系了,完美AC!!!



京公网安备 11010502036488号