Advertisement
Ryuuk

Ibrahim

May 16th, 2018
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.67 KB | None | 0 0
  1. //author: Ryuuk
  2. //Date: 2018-05-16 20:51:42
  3. #include<bits/stdc++.h>
  4. #define sz(a) int((a).size())
  5. #define pb push_back
  6. #define all(c) (c).begin(),(c).end()
  7. #define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
  8. #define present(c,x) ((c).find(x) != (c).end())
  9. #define cpresent(c,x) (find(all(c),x) != (c).end())
  10. #define LSOne(i) (i&(-i))
  11. #define rep(i,a,b) for(int(i)=(a);(i)<(b);i++)
  12. #define BUG(x) {cout<<#x<<" = "<<x<<endl;}
  13. #define left(x) (x<<1)
  14. #define right(x) ((x<<1) +1)
  15. #define middle(s,e)(s+(e-s)/2)
  16. #define size_tree(n) 2*(int)pow(2,ceil(log2(n)))
  17. #define CL(A,I) (memset(A,I,sizeof(A)))
  18. #define endl '\n'
  19.  
  20. static const int INF = 0x3f3f3f3f;
  21. static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
  22. static const long double epsilon = 1e-15;
  23. static const long double pi = acos((long double) -1);
  24. using namespace std;
  25. inline void init_io(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
  26.  
  27. typedef vector<int> vi;
  28. typedef vector<vi> vvi;
  29. typedef pair<int,int> ii;
  30. typedef long long ll;
  31.  
  32.  
  33. int main()
  34. {
  35.     #ifndef ONLINE_JUDGE
  36.         freopen("input.txt","r",stdin);
  37.         //freopen("output.txt","w",stdout);
  38.     #endif // ONLINE_JUDGE
  39.     init_io();
  40.     int n,q,b;
  41.     string s,s2;
  42.     cin>>n>>s>>q;
  43.    
  44.     for (int i=0; i<n/2; i++)
  45.        swap(s[i], s[n-i-1]);
  46.  
  47.     s2 = s;
  48.     int last = 0,offset = 0;
  49.  
  50.     rep(i,0,s.size())
  51.       if(s[i]-'0'==1)
  52.         last = i ;
  53.  
  54.     rep(i,0,q)
  55.     {
  56.       cin>>offset;
  57.       for(int j=offset;j<=last;j++)
  58.         s2[j-offset] = char(((s2[j-offset]-'0') | (s[j]-'0'))+'0');
  59.     }
  60.  
  61.     for (int i=0; i<n/2; i++)
  62.        swap(s2[i], s2[n-i-1]);
  63.      cout<<s2<<endl;
  64.     return 0;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement