fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int p[100001], r[100001];
  4. int main() {
  5. int n, a[7];
  6. cin >> n;
  7. for (int i = 1; i <= n; i++) cin >> p[i];
  8. for (int i = 1; i <= 5; i++) cin >> a[i];
  9. cin >> a[7];
  10. a[6] = a[2];
  11. a[8] = a[4];
  12. if (n <= 7) {
  13. cout << 0 << endl;
  14. for (int i = 1; i < n; i++) cout << p[i] << ' ';
  15. cout << p[n] << endl;
  16. } else if (n <= 8) {
  17. bool same = true;
  18. for (int i = 1; i <= 8; i++) {
  19. if (p[i] != a[i]) same = false;
  20. }
  21. if (same) cout << 1 << endl << endl;
  22. else {
  23. cout << 0 << endl;
  24. for (int i = 1; i < n; i++) cout << p[i] << ' ';
  25. cout << p[n] << endl;
  26. }
  27. } else {
  28. int total = 0;
  29. for (int i = 1; i <= n; i++) {
  30. bool same = true;
  31. for (int k = i; k <= i + 8; k++) {
  32. if (p[k] != a[k]) same = false;
  33. }
  34. if (same) {
  35. total++;
  36. for (int k = 1; k <= 8; k++) r[k] = 1;
  37. }
  38. }
  39. cout << total << endl;
  40. int last = n;
  41. while (r[last] == 1) last--;
  42. for (int i = 1; i < last; i++) {
  43. if (r[k] == 0) cout << p[k] << ' ';
  44. }
  45. cout << p[last] << endl;
  46. }
  47. return 0;
  48. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:43:10: error: ‘k’ was not declared in this scope
    if (r[k] == 0) cout << p[k] << ' ';
          ^
stdout
Standard output is empty