Advertisement
Saleh127

CF 1382 C1,C2

Sep 14th, 2020
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(0);
  8. cin.tie(0);
  9. cout.tie(0);
  10.  
  11. test
  12. {
  13. ll d,i,j,k,l;
  14.  
  15. cin>>d;
  16. string a,c;
  17. vector<ll>ans;
  18.  
  19. cin>>a>>c;
  20.  
  21. for(i=1; i<d; i++)
  22. {
  23. if(a[i]!=a[i-1])
  24. {
  25. ans.push_back(i);
  26. if(a[0]=='0') a[0]='1';
  27. else a[0]='0';
  28. }
  29. }
  30.  
  31. for(i=d-1; i>=0; i--)
  32. {
  33. if(c[i]!=a[0])
  34. {
  35. ans.push_back(i+1);
  36. if(a[0]=='0') a[0]='1';
  37. else a[0]='0';
  38. }
  39. }
  40.  
  41. cout<<ans.size();
  42. for(i=0; i<ans.size(); i++)
  43. {
  44. cout<<" "<<ans[i];
  45. }
  46. cout<<endl;
  47. }
  48.  
  49.  
  50. return 0;
  51. }
  52.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement