fork download
  1. #include <bits/stdc++.h>
  2. #define ll long long int
  3. #define ld long double
  4. #define nl "\n"
  5. #define ull unsigned long long
  6. #define rv return void
  7. #define str string
  8. #define all(x) x.begin(), x.end()
  9. #define allr(x) x.rbegin(), x.rend()
  10. #define vec vector
  11. #define fixed(n) fixed << setprecision(n)
  12. #define Moageza ios::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);
  13. using namespace std;
  14. const ll mod = 1e9+7;
  15. struct SegmentTree{
  16. private:
  17. #define L 2*node+1
  18. #define R 2*node+2
  19. #define mid (l+r>>1)
  20. ll sz,skip=LLONG_MAX;
  21. vector<ll>seg,lazy;
  22. void propegate(int l,int r,int node)
  23. {
  24. if(lazy[node]==LLONG_MAX)return;
  25. if(l!=r)
  26. {
  27. lazy[L]=lazy[node];
  28. lazy[R]=lazy[node];
  29.  
  30. }
  31. seg[node]=lazy[node];
  32. lazy[node]=LLONG_MAX;
  33. }
  34. void update(int l,int r,int node,int lx,int rx,ll val)
  35. {
  36. propegate(l,r,node);
  37. if(l>rx||r<lx)
  38. {
  39. return;
  40. }
  41. if(l>=lx&&r<=rx)
  42. {
  43. lazy[node]=val;
  44. propegate(l,r,node);
  45. return;
  46. }
  47. update(l,mid,L,lx,rx,val);
  48. update(mid+1,r,R,lx,rx,val);
  49. seg[node]=min(seg[L],seg[R]);
  50. }
  51. ll query(int l,int r,int node,int lx,int rx)
  52. {
  53. propegate(l,r,node);
  54. if(l>=lx&&r<=rx)
  55. {
  56. return seg[node];
  57. }
  58. if(l>rx||r<lx)
  59. {
  60. return skip;
  61. }
  62. // if I move right or left
  63. // propegate(l,mid,L);
  64. // propegate(mid+1,r,R);
  65. return min(query(l,mid,L,lx,rx),query(mid+1,r,R,lx,rx));
  66. }
  67. public:
  68. SegmentTree(int n){
  69. sz=1;
  70. while(sz<n)sz*=2;
  71. seg=vector<ll>(sz*2,0);
  72. lazy=vector<ll>(sz*2,0);
  73. }
  74. void update(int l,int r,ll val)
  75. {
  76. update(0,sz-1,0,l,r,val);
  77. }
  78. ll query(int l, int r) {
  79. if( query(0, sz - 1, 0, l, r)==LLONG_MAX)return 0;
  80. return query(0, sz - 1, 0, l, r);
  81. }
  82. };
  83. void solve(){
  84. int n,q;cin>>n>>q;
  85. SegmentTree st(n);
  86. while(q--)
  87. {
  88. int op;cin>>op;
  89. if(op==1)
  90. {
  91. ll l,r,val;cin>>l>>r>>val;
  92. st.update(l,r-1,val);
  93. }
  94. else
  95. {
  96. int l,r;cin>>l;
  97. cout<<st.query(l,l)<<nl;
  98. }
  99. }
  100. }
  101. int main()
  102. {
  103. Moageza
  104. #ifndef ONLINE_JUDGE
  105. freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
  106. #endif
  107. int t = 1;
  108. // cin >> t;
  109. while (t--) {
  110. solve();
  111. cout << nl;
  112. }
  113. return 0;
  114. }
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout