fork(1) download
  1. #include <vector>
  2. #include <iostream>
  3. #include <algorithm>
  4. #include <iterator>
  5.  
  6. enum{FIRST, SECOND};
  7.  
  8. int query(std::vector<int>& v, int type)
  9. {
  10. int start, end;
  11. if(type == FIRST)
  12. {
  13. std::cin >> start;
  14. v.erase(v.begin() + start - 1);
  15. return 1;
  16. }
  17. if(type == SECOND)
  18. {
  19. std::cin >> start >> end;
  20. v.erase(v.begin() + start - 1, v.begin() + end - 1);
  21. return 1;
  22. }
  23. return -1;
  24. }
  25.  
  26. void answer(std::vector<int>& v)
  27. {
  28. if(v.size() > 0)
  29. {
  30. std::cout << v.size() << std::endl;
  31. std::copy(v.begin(), v.end(), std::ostream_iterator<int>(std::cout, " "));
  32. }
  33. }
  34.  
  35. int main() {
  36. int n, value; // number of elements
  37. std::vector<int> numbers;
  38.  
  39. std::cin >> n;
  40. for(int i = 0; i < n; i++)
  41. {
  42. std::cin >> value;
  43. numbers.push_back(value);
  44. }
  45. query(numbers, FIRST);
  46. query(numbers, SECOND);
  47. answer(numbers);
  48. return 0;
  49. }
Runtime error #stdin #stdout #stderr 4.55s 528896KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc