fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. const int N=2e5+5;
  5. int tree[4*N], sz;
  6.  
  7. void init(int n)
  8. {
  9. sz=1;
  10. while(sz<n)
  11. sz*=2;
  12. }
  13.  
  14. int query(int i, int node, int lx, int rx)
  15. {
  16. if(rx-lx==1)
  17. return tree[node];
  18. int mid=(lx+rx)/2;
  19. if(tree[node]!=-1)
  20. {
  21. tree[2*node+1]=tree[node];
  22. tree[2*node+2]=tree[node];
  23. }
  24. tree[node]=-1;
  25. if(i<mid)
  26. return query(i, 2*node+1, lx, mid);
  27. return query(i, 2*node+2, mid, rx);
  28. }
  29.  
  30. void update(int l, int r, int v, int node, int lx, int rx)
  31. {
  32. if(lx>=r || rx<=l)
  33. return;
  34. if(lx>=l && rx<=r)
  35. {
  36. tree[node]=v;
  37. return;
  38. }
  39. int mid=(lx+rx)/2;
  40. update(l, r, v, 2*node+1, lx, mid);
  41. update(l, r, v, 2*node+2, mid, rx);
  42. }
  43.  
  44. void solve()
  45. {
  46. int n, m;
  47. cin>>n>>m;
  48.  
  49. for(int i=0;i<4*N;i++)
  50. tree[i]=-1;
  51.  
  52. init(n);
  53.  
  54. while(m--)
  55. {
  56. int op;
  57. cin>>op;
  58. if(op==2)
  59. {
  60. int i;
  61. cin>>i;
  62. int ans=query(i, 0, 0, sz);
  63. if(ans==-1)
  64. cout<<0<<endl;
  65. else
  66. cout<<ans<<endl;
  67. }
  68. else
  69. {
  70. int l, r, v;
  71. cin>>l>>r>>v;
  72. update(l, r, v, 0, 0, sz);
  73. }
  74. }
  75.  
  76.  
  77. }
  78.  
  79. signed main() {
  80.  
  81. fastio
  82.  
  83. // int t;cin>>t;while(t--)
  84. solve();
  85.  
  86.  
  87. return 0;
  88. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:81:5: error: ‘fastio’ was not declared in this scope
     fastio
     ^~~~~~
prog.cpp:81:5: note: suggested alternative: ‘asin’
     fastio
     ^~~~~~
     asin
stdout
Standard output is empty