Advertisement
Guest User

Untitled

a guest
Feb 21st, 2020
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. #include <unordered_map>
  2. #include <string>
  3. #include <stdio.h>
  4. #include <iostream>
  5. #include<unordered_map>
  6. #include <bits/stdc++.h>
  7. using namespace std;
  8. int main()
  9. {
  10. unordered_map<int, int> umap;
  11. int n;
  12. cin>>n;
  13. vector< vector<int> > allgroup(n);
  14.  
  15. string strs;
  16. cin>>strs;
  17. int flag = 0;
  18. int curchar = 0;
  19. int getsize = 1;
  20. for(int i = 0 ; i < n; i++){
  21. flag = 0;
  22. if (i == 0){
  23. umap[i] = 0;
  24. allgroup[0].push_back((int)strs[i]);
  25. continue;
  26. }
  27. curchar = (int)strs[i];
  28. // cout<<curchar<<endl;
  29. for (int j = 0; j < allgroup.size(); j++){
  30.  
  31. if (allgroup[j].size() == 0){
  32. allgroup[j].push_back(curchar);
  33. umap[i] = j;
  34. flag = 1;
  35. break;
  36. }
  37.  
  38. else if (allgroup[j].back() <= curchar){
  39. allgroup[j].push_back(curchar);
  40. umap[i] = j;
  41. flag = 1;
  42. break;
  43. }
  44. }
  45.  
  46. // if (flag == 0){
  47. // getsize++;
  48. // umap[i] = getsize;
  49. // allgroup[getsize].push_back((int)strs[i]);
  50. // }
  51.  
  52. }
  53.  
  54. int out = 0;
  55. // cout<<out<<endl;
  56. for (int i = 0; i < n; i++){
  57. // cout<<out<<endl;
  58. out = umap[i] + 1;
  59. cout<<out;
  60. if (i != n -1){
  61. cout<<" ";
  62. }
  63. }
  64.  
  65. return 0;
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement