This documentation is automatically generated by online-judge-tools/verification-helper
View the Project on GitHub beet-aizu/library
// verification-helper: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_D #include <bits/stdc++.h> using namespace std; #define call_from_test #include "../../segtree/basic/dual.cpp" #undef call_from_test signed main(){ cin.tie(0); ios::sync_with_stdio(0); int n,q; cin>>n>>q; auto h=[](int a,int b){(void)a;return b;}; int ei=INT_MAX; SegmentTree<int> seg(h,ei); seg.init(n); for(int i=0;i<q;i++){ int tp; cin>>tp; if(tp==0){ int s,t,x; cin>>s>>t>>x; seg.update(s,t+1,x); } if(tp==1){ int s; cin>>s; cout<<seg.get_val(s)<<"\n"; } } cout<<flush; return 0; }
#line 1 "test/aoj/DSL_2_D.test.cpp" // verification-helper: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_D #include <bits/stdc++.h> using namespace std; #define call_from_test #line 1 "segtree/basic/dual.cpp" #line 3 "segtree/basic/dual.cpp" using namespace std; #endif //BEGIN CUT HERE template <typename E> struct SegmentTree{ using H = function<E(E,E)>; int n,height; H h; E ei; vector<E> laz; SegmentTree(H h,E ei):h(h),ei(ei){} void init(int n_){ n=1;height=0; while(n<n_) n<<=1,height++; laz.assign(2*n,ei); } inline void propagate(int k){ if(laz[k]==ei) return; laz[(k<<1)|0]=h(laz[(k<<1)|0],laz[k]); laz[(k<<1)|1]=h(laz[(k<<1)|1],laz[k]); laz[k]=ei; } inline void thrust(int k){ for(int i=height;i;i--) propagate(k>>i); } void update(int a,int b,E x){ if(a>=b) return; thrust(a+=n); thrust(b+=n-1); for(int l=a,r=b+1;l<r;l>>=1,r>>=1){ if(l&1) laz[l]=h(laz[l],x),l++; if(r&1) --r,laz[r]=h(laz[r],x); } } E get_val(int a){ thrust(a+=n); return laz[a]; } void set_val(int a,E x){ thrust(a+=n); laz[a]=x; } }; //END CUT HERE #ifndef call_from_test //INSERT ABOVE HERE signed main(){ return 0; } #endif #line 8 "test/aoj/DSL_2_D.test.cpp" #undef call_from_test signed main(){ cin.tie(0); ios::sync_with_stdio(0); int n,q; cin>>n>>q; auto h=[](int a,int b){(void)a;return b;}; int ei=INT_MAX; SegmentTree<int> seg(h,ei); seg.init(n); for(int i=0;i<q;i++){ int tp; cin>>tp; if(tp==0){ int s,t,x; cin>>s>>t>>x; seg.update(s,t+1,x); } if(tp==1){ int s; cin>>s; cout<<seg.get_val(s)<<"\n"; } } cout<<flush; return 0; }