Ankit_132

E

Jun 6th, 2023
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.73 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 pb     push_back
  9. #define ppb    pop_back
  10.  
  11.  
  12. int main()
  13. {
  14.     _test
  15.     {
  16.         string a, b;
  17.         cin>>a>>b;
  18.  
  19.         int t, q;
  20.         cin>>t>>q;
  21.  
  22.         int diff = 0;
  23.  
  24.         int n = a.size();
  25.  
  26.         for(int i=0; i<n; i++)
  27.             diff += (a[i] != b[i]);
  28.  
  29.         vector<vector<int>> blocked(2*q+5);
  30.         int currTime = 1;
  31.         int Q = q;
  32.  
  33.         while(Q--)
  34.         {
  35.             int type;
  36.             cin>>type;
  37.  
  38.             for(auto i: blocked[currTime])
  39.                 diff += (a[i] != b[i]);
  40.  
  41.             if(type == 3)
  42.                 cout<<((diff==0)?"YES\n":"NO\n");
  43.             else if(type == 1)
  44.             {
  45.                 int i;
  46.                 cin>>i;
  47.                 i--;
  48.  
  49.                 diff -= (a[i] != b[i]);
  50.  
  51.                 if(currTime+t <= 2*q)     blocked[currTime+t].pb(i);
  52.             }
  53.             else if(type == 2)
  54.             {
  55.                 int x, p1, y, p2;
  56.                 cin>>x>>p1>>y>>p2;
  57.  
  58.                 p1--, p2--;
  59.  
  60.                 diff -= (a[p1] != b[p1]);
  61.                 diff -= (a[p2] != b[p2]);
  62.  
  63.                 if(x == y)
  64.                 {
  65.                     if(x == 1)
  66.                         swap(a[p1], a[p2]);
  67.                     else
  68.                         swap(b[p1], b[p2]);
  69.                 }
  70.                 else
  71.                 {
  72.                     if(x==2)        swap(p1, p2);
  73.                     swap(a[p1], b[p2]);
  74.                 }
  75.  
  76.                 diff += (a[p1] != b[p1]);
  77.                 diff += (a[p2] != b[p2]);
  78.             }
  79.  
  80.             currTime++;
  81.         }
  82.     }
  83. }
  84.  
Advertisement
Add Comment
Please, Sign In to add comment