fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. using ivector = vector<int>;
  6. const auto generate = true;
  7. const vector<string> ans = {"NO","YES"};
  8. int N;
  9. ivector A;
  10. if (cin >> N, A.resize(N), generate) {
  11. using namespace chrono;
  12. using clock = high_resolution_clock;
  13. const auto now = clock::now();
  14. const auto time = now.time_since_epoch();
  15. const auto seed = time.count();
  16. mt19937_64 random(seed);
  17. int max_value;
  18. cin >> max_value;
  19. cout << "Test:" << endl << N << endl;
  20. uniform_int_distribution<int> uniform(1,max_value);
  21. for (auto& elem: A) {
  22. elem = uniform(random);
  23. cout << elem << ' '; }
  24. cout << endl << "Output:" << endl; }
  25. else
  26. for (auto& elem: A)
  27. cin >> elem;
  28. const auto good_array = [&](const int p) {
  29. ivector a(A.cbegin(),A.cend());
  30. const auto valid_parity = [&](int i) { return (a[i]&1) == p; };
  31. const int last = N-1;
  32. for (int i = 0; i < last; ++i)
  33. if (!valid_parity(i))
  34. ++a[i], ++a[i+1];
  35. return valid_parity(last); };
  36. cout << ans[good_array(0) or good_array(1)];
  37. return 0; }
  38.  
Success #stdin #stdout 0s 5544KB
stdin
10 10
stdout
Test:
10
4 1 1 7 5 3 5 1 1 7 
Output:
NO