Ankit_132

D

Aug 13th, 2023
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.26 KB | None | 0 0
  1.  
  2. #include <bits/stdc++.h>
  3.  
  4. using namespace std;
  5.  
  6. #define ll     long long
  7. #define _test   int _TEST; cin>>_TEST; while(_TEST--)
  8. #define ff     first
  9. #define ss     second
  10. #define pb     push_back
  11.  
  12. int main()
  13. {
  14.     ios_base::sync_with_stdio(false);
  15.     cin.tie(NULL);
  16.     cout.tie(NULL);
  17.  
  18.     int n;
  19.     string s;
  20.     cin>>n>>s;
  21.  
  22.     int q;
  23.     cin>>q;
  24.  
  25.     vector<pair<pair<int, int>, char>> va(q);
  26.  
  27.     for(auto &e: va)
  28.         cin>>e.ff.ff>>e.ff.ss>>e.ss;
  29.  
  30.     int f = 0;
  31.  
  32.     string ans(n, '.');
  33.  
  34.     for(int i=q-1; i>=0; i--)
  35.     {
  36.         int t = va[i].ff.ff;
  37.         int x = va[i].ff.ss;
  38.         char c = va[i].ss;
  39.  
  40.         if(t == 1)
  41.         {
  42.             if(ans[x-1] != '.') continue;
  43.             if(!f)              ans[x-1] = c;
  44.             else if(f == 1)     ans[x-1] = toupper(c);
  45.             else if(f == 2)     ans[x-1] = tolower(c);
  46.         }
  47.         else if(t == 2 && !f)         f = 2;
  48.         else if(t == 3 && !f)         f = 1;
  49.     }
  50.  
  51.     for(int i=0; i<n; i++)
  52.     {
  53.         if(ans[i] == '.')
  54.         {
  55.             if(!f)              ans[i] = s[i];
  56.             else if(f == 1)     ans[i] = toupper(s[i]);
  57.             else if(f == 2)     ans[i] = tolower(s[i]);
  58.         }
  59.     }
  60.  
  61.     cout<<ans<<"\n";
  62. }
  63.  
Advertisement
Add Comment
Please, Sign In to add comment