fork(1) download
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int t;
  8. cin>>t;
  9. ios::sync_with_stdio(false);
  10.  
  11.  
  12. while(t--)
  13. {
  14. char kolejka[1000000] = {0};
  15. cin>> kolejka;
  16. int rozmiar = strlen(kolejka);
  17. int maks = kolejka[rozmiar-1];
  18.  
  19. for(int i = rozmiar - 1; i > 0; i-- )
  20. {
  21. if(kolejka[i-1] < maks)
  22. kolejka[i-1] = '*'; //tylko dla pokazania Ci błędu, zamiast 0
  23.  
  24. else if ( kolejka[i-1] > maks)
  25. maks = kolejka[i-1];
  26. }
  27. for(int x=0; x < rozmiar; x++)
  28. cout<<kolejka[x];
  29.  
  30. }
  31.  
  32.  
  33. return 0;
  34. }
Success #stdin #stdout 0s 4584KB
stdin
2
klkkn
klKKnNLlNL
stdout
****n****n**lNL