Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <vector>
  4. #include <string>
  5. using namespace std;
  6. int main()
  7. {
  8. ifstream cin("set.in");
  9. ofstream cout("set.out");
  10. string s;
  11. vector <vector<int>> a(1e6 + 7);
  12. int t;
  13. bool flag;
  14. while (cin >> s)
  15. {
  16. cin >> t;
  17. if (s[0] == 'i')
  18. {
  19. flag = false;
  20. for (int i = 0; i < a[abs(t) % 1000007].size(); i++)
  21. if (a[abs(t) % 1000007][i] == t) flag = true;
  22. if(flag==false)
  23. a[abs(t) % 1000007].push_back(t);
  24. }
  25. else if (s[0] == 'e')
  26. {
  27. flag = false;
  28. for (int i = 0; i < a[abs(t) % 1000007].size(); i++)
  29. if (a[abs(t) % 1000007][i] == t) { flag=true; break; }
  30. if (flag)
  31. cout << "true\n";
  32. else
  33. cout << "false\n";
  34. }
  35. else if (s[0] == 'd')
  36. {
  37. for (auto i = a[abs(t) % 1000007].begin(); i != a[abs(t) % 1000007].end(); i++)
  38. if (*i == t) {
  39. a[abs(t) % 1000007].erase(i);
  40. break;
  41. }
  42. }
  43. }
  44. return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement