fork download
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3. const ll MAXN=2e5;
  4. using namespace std;
  5. ll n,q,a[MAXN+5],b[MAXN+5];
  6. ll lazy[4*MAXN+5];
  7. void push(ll v){
  8. if(lazy[v]==1e18) return;
  9. lazy[2*v]=lazy[v];
  10. lazy[2*v+1]=lazy[v];
  11. lazy[v]=1e18;
  12. }
  13. void update(ll v,ll tl,ll tr,ll l,ll r,ll x,ll y){
  14. if(l>r) return;
  15. if(tl==l && tr==r) lazy[v]=x-y;
  16. else{
  17. push(v);
  18. ll tm=(tl+tr)/2;
  19. update(2*v,tl,tm,l,min(r,tm),x,y);
  20. update(2*v+1,tm+1,tr,max(l,tm+1),r,x,y);
  21. }
  22. }
  23. ll query(ll v,ll l,ll r,ll pos){
  24. if(l==r) return lazy[v];
  25. else{
  26. push(v);
  27. ll m=(l+r)/2;
  28. if(pos<=m) return query(2*v,l,m,pos);
  29. else return query(2*v+1,m+1,r,pos);
  30. }
  31. }
  32. int main(){
  33. ios_base::sync_with_stdio(0);cin.tie(0);
  34. if(fopen("skibidi.inp","r")){
  35. freopen("skibidi.inp","r",stdin);
  36. freopen("skibidi.out","w",stdout);
  37. }
  38. cin>>n>>q;
  39. for(int i=1;i<=n;i++) cin>>a[i];
  40. for(int i=1;i<=n;i++) cin>>b[i];
  41. for(int i=0;i<=4*MAXN;i++) lazy[i]=1e18;
  42. while(q--){
  43. ll type;
  44. cin>>type;
  45. if(type==1){
  46. ll x,y,k;
  47. cin>>x>>y>>k;
  48. update(1,1,n,y,y+k-1,x,y);
  49. }
  50. else{
  51. ll i;
  52. cin>>i;
  53. ll tmp=query(1,1,n,i);
  54. if(tmp==1e18) cout<<b[i];
  55. else cout<<a[tmp+i];
  56. cout<<'\n';
  57. }
  58. }
  59. return 0;
  60. }
  61.  
Success #stdin #stdout 0.01s 10372KB
stdin
Standard input is empty
stdout
Standard output is empty