fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. const vector<string> ans = {"NO","YES"};
  6. const auto expected = [&](int N) {
  7. int parity, count[2] = {};
  8. for (auto digit: to_string(N))
  9. ++count[parity = (digit-'0')&1];
  10. return ans[count[parity] > 1]; };
  11. const auto buggy = [&](int N) {
  12. enum {NO,YES};
  13. if (N == 10)
  14. return ans[NO];
  15. const auto parity = [&](int x) { return x%2; };
  16. for (int a, b, div = 10; N/div > 0; div *= 10)
  17. if (a = N/div, b = N%div, a == 0 or b == 0)
  18. continue;
  19. else if (parity(a) == parity(b))
  20. return ans[YES];
  21. return ans[NO]; };
  22. const auto hack_code = [&]() {
  23. const auto now = chrono::high_resolution_clock::now();
  24. const auto time = now.time_since_epoch();
  25. const auto seed = time.count();
  26. mt19937_64 random(seed);
  27. uniform_int_distribution<int> uniform(10,1e9);
  28. int N; string B, E;
  29. do
  30. N = uniform(random), E = expected(N), B = buggy(N);
  31. while (B == E);
  32. cout << "Hacking test-case" << endl,
  33. cout << "N = " << N << endl,
  34. cout << "Buggy answer: " << B << endl,
  35. cout << "Expected answer: " << E << endl; };
  36. const auto submission_code = [&]() {
  37. int T; cin.tie(nullptr)->sync_with_stdio(false), cin >> T;
  38. for (int N; T--; cout << expected(N) << '\n')
  39. cin >> N; };
  40. const auto test = true;
  41. if (test)
  42. hack_code();
  43. else
  44. submission_code();
  45. return 0; }
  46.  
Success #stdin #stdout 0.01s 5436KB
stdin
Standard input is empty
stdout
Hacking test-case
N = 955375720
Buggy    answer: NO
Expected answer: YES