#include #include #include int n,X,Y,Z,T; int number; std::string currentTime; std::vector isPeculiar; int main() { std::cin >> n; isPeculiar.resize(n); for (int i = 0; i < n; ++i) { isPeculiar[i] = false; std::cin >> currentTime; //check if it's valid X = int(currentTime[0]) - int('0'); if (X >= 3) continue; Y = int(currentTime[1]) - int('0'); if (X == 2 && Y >= 4) continue; Z = int(currentTime[3]) - int('0'); if (Z >= 6) continue; T = int(currentTime[4]) - int('0'); //check if it's an exact hour if (Z + T == 0) { isPeculiar[i] = true; continue; } //check if it's doubled time if (X == Z && Y == T) { isPeculiar[i] = true; continue; } //check if it's mirrored time if (X == T && Y == Z) { isPeculiar[i] = true; continue; } //check if it has increasing consecutive digits if (T == Z + 1) if (Z == Y + 1) if (Y == X + 1) { isPeculiar[i] = true; continue; } //check if it's a power of two number = X * 1000 + Y * 100 + Z * 10 + T; if (number > 1 && number >= 1024) { while (number % 2 == 0) number /= 2; if (number == 1) { isPeculiar[i] = true; continue; } } } for (int i = 0; i < n; ++i) if (isPeculiar[i]) std::cout << "YES\n"; else std::cout << "NO\n"; return 0; }