Advertisement
Guest User

Untitled

a guest
Apr 24th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int n;
  8. cin >> n;
  9. string str;
  10. cin >> str;
  11. vector<char> v(n);
  12. set<char> s;
  13. for(int i = 0; i < n; i++) {
  14. v[i] = str[i];
  15. s.insert(v[i]);
  16. }
  17. for(auto i = s.begin(); i != s.end(); i++) {
  18. cout << *i << " ";
  19. }
  20. int flats = 0;
  21. cout << m;
  22. auto beg = v.begin();
  23. auto end = v.begin();
  24. map<int, int> mym;
  25. while(beg != v.end()) {
  26. while(mym.size() != m && end != v.end()) {
  27. mym[*(end++)]++;
  28. }
  29. cout << (end - beg) << endl;
  30. if(mym.size() == m) flats = min(flats, end - beg);
  31. if(mym[*beg] == 1) {
  32. mym.erase(beg);
  33. }
  34. else {
  35. mym[*beg]--;
  36. }
  37. beg++;
  38. }
  39. cout << flats;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement