Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define _test int _TEST; cin>>_TEST; while(_TEST--)
- #define pb push_back
- #define ppb pop_back
- int main()
- {
- _test
- {
- string a, b;
- cin>>a>>b;
- int t, q;
- cin>>t>>q;
- int diff = 0;
- int n = a.size();
- for(int i=0; i<n; i++)
- diff += (a[i] != b[i]);
- vector<vector<int>> blocked(2*q+5);
- int currTime = 1;
- int Q = q;
- while(Q--)
- {
- int type;
- cin>>type;
- for(auto i: blocked[currTime])
- diff += (a[i] != b[i]);
- if(type == 3)
- cout<<((diff==0)?"YES\n":"NO\n");
- else if(type == 1)
- {
- int i;
- cin>>i;
- i--;
- diff -= (a[i] != b[i]);
- if(currTime+t <= 2*q) blocked[currTime+t].pb(i);
- }
- else if(type == 2)
- {
- int x, p1, y, p2;
- cin>>x>>p1>>y>>p2;
- p1--, p2--;
- diff -= (a[p1] != b[p1]);
- diff -= (a[p2] != b[p2]);
- if(x == y)
- {
- if(x == 1)
- swap(a[p1], a[p2]);
- else
- swap(b[p1], b[p2]);
- }
- else
- {
- if(x==2) swap(p1, p2);
- swap(a[p1], b[p2]);
- }
- diff += (a[p1] != b[p1]);
- diff += (a[p2] != b[p2]);
- }
- currTime++;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment