Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 3):


    #include <bits/stdc++.h> // include all standard headers
    using namespace std;
     
    #define ll long long
    #define ld long double
    #define pii pair<int, int>
    #define mp make_pair
    #define pb push_back
    #define eb emplace_back
    #define fi first
    #define se second
     
    const int INF = 1e9;
    const ll INFLL = 1e18;
    const int MOD = 1e9 + 7;

    char rect(vector<char> &s){
        int n=s.size();
     
    
     char max=s[0];
     int ind=0;
        for(int i=1; i<min(n,10); i++){
          if(s[i]-i>max){
          max=s[i]-i;
          ind=i;
        }}
        s.erase(s.begin()+ind);
        return max;
    
    }
    int main() {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        
        // Declare any additional variables here
        
        int t; // number of test cases
        cin >> t;
        
        while (t--) {
          string s;
          cin >> s;
          ll n;
          n=s.size();
          int k=n/10;
          int g=k;
          while(k--){
          int j=0;
         vector<char> v;
         int p=0;
         for(int i=j*10;i<(j+1)*10;i++){
            v.pb(s[p]);
            p++;
         }
       int size=v.size();
        for(int i=0;i<size;i++)
        cout<<rect(v);
        j++;
       
        }
        int h=(n-(g*10));
       
        vector<char> v;
        int l=0;
        for(int i=n-h;i<n;i++){
        v.pb(s[l]);
        l++;
        }
        int size=v.size();
        for(int i=0;i<size;i++)
        cout<<rect(v);
        cout<<"\n";
        }
       
        
        return 0;
    }




Submission (verdict: Accepted):


    #include <bits/stdc++.h> // include all standard headers
    using namespace std;
     
    #define ll long long
    #define ld long double
    #define pii pair<int, int>
    #define mp make_pair
    #define pb push_back
    #define eb emplace_back
    #define fi first
    #define se second
     
    const int INF = 1e9;
    const ll INFLL = 1e18;
    const int MOD = 1e9 + 7;

    char rect(vector<char> &s){
        int n=s.size();
     
    
     char max=s[0];
     int ind=0;
        for(int i=1; i<min(n,10); i++){
          if(s[i]-i>max){
          max=s[i]-i;
          ind=i;
        }}
        s.erase(s.begin()+ind);
        return max;
    
    }
    int main() {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        
        // Declare any additional variables here
        
        int t; // number of test cases
        cin >> t;
        
        while (t--) {
          string s;
          cin >> s;
          ll n;
          n=s.size();
          vector<char> v;
          if(n>9){
          for(int i=0; i<10;i++)
           v.pb(s[i]);
           cout<<rect(v);
           for(int i=10;i<n;i++){
            v.pb(s[i]);
           cout<<rect(v);}
           for(int i=0;i<9;i++){
               cout<<rect(v);
           }
          
          }
          else{
        for(int i=0;i<n;i++){
        v.pb(s[i]);
        }
        int size=v.size();
        for(int i=0;i<size;i++)
        cout<<rect(v);
          }
        cout<<"\n";
         
        }
       
        
        return 0;
    }