Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //https://codeforces.com/edu/course/2/lesson/4/1/practice/contest/273169/problem/C
- #pragma GCC optimize ("Ofast,unroll-loops")
- #pragma GCC target ("avx2,fma")
- #include<bits/stdc++.h>
- //#include <ext/pb_ds/assoc_container.hpp>
- //using namespace __gnu_pbds;
- using namespace std;
- /*typedef tree<long long,null_type,greater<>, rb_tree_tag,\
- tree_order_statistics_node_update> indexed_set;*/
- //rope
- #define forx(i,a,b) for (long long i = a; i < b; i++)
- #define INF 1e10
- #define all(x2) begin(x2),end(x2)
- #define isz(t) ((ull)(t.size()))
- #define last(x) (*(x.end()-1))
- #define mod ll(1e9+7)
- using ll= long long;
- using ld= long double;
- using ull=unsigned long long;
- struct point{
- double x,y;
- point(const double & x,const double & y){
- this->x=x;
- this->y=y;
- }
- point operator +(point& b) const{
- return {this->x+b.x,this->y+b.y};
- }
- point operator -(const point& b) const{
- return {this->x-b.x,this->y-b.y};
- }
- point operator *(point& b) const{
- return {this->x*b.x,this->y*b.y};
- }
- point operator /(point& b) const{
- return {this->x/b.x,this->y/b.y};
- }
- double cross(point& b){
- return this->x*b.y-this->y*b.x;
- }
- double cross(const point& a,const point& b){
- return a.x*b.y-a.y*b.x;
- }
- double dott(const point& b) const {
- return this->x*b.x+this->y*b.y;
- }
- double len() const {
- return sqrt(this->dott(*this));
- }
- double len(const point& a){
- return sqrt(a.dott(a));
- }
- double angle(const point& b){
- return acos(dott(b)/len()/b.len());
- }
- double dist_to_line(point p1,point p2,point A){
- return abs(cross(p2-A,p1-A)/len(p1-p2));
- }
- };
- /*cout.setf(ios::fixed);
- cout.precision(6);*/
- #define declare ull mid=(left+right)/2,v_left=v*2,v_right=v*2+1
- class seg_tree{
- ull start,end,pos,x;
- vector<ull>arr;
- vector<ull>tree;
- vector<ull>num;
- void clear(ull v){
- tree[v]=INF;
- num[v]=0;
- }
- void accum(ull v_left,ull v_right){
- if(tree[v_right]<tree[v_left])
- num[v_left]=num[v_right];
- if(tree[v_right]==tree[v_left])
- num[v_left]+=num[v_right];
- tree[v_left]=min(tree[v_right], tree[v_left]);
- }
- void update(ull v,ull v_left,ull v_right){
- clear(v);
- accum(v,v_left);
- accum(v,v_right);
- }
- void build(ull v, ull left, ull right){
- if(left+1==right) {
- tree[v] = arr[left];
- num[v] = 1;
- }
- else{
- declare;
- build(v_left,left,mid);
- build(v_right,mid,right);
- update(v,v_left,v_right);
- }
- }
- void get_tr(ull v, ull left, ull right){
- if(start<=left && right<=end)
- accum(0,v);
- else{
- declare;
- if(start<mid)
- get_tr(v_left,left,mid);
- if(mid<end)
- get_tr(v_right,mid,right);
- }
- }
- void change_tr(ull v, ull left, ull right){
- if(left+1==right)
- tree[v]=x;
- else{
- declare;
- if(pos<mid)
- change_tr(v_left,left,mid);
- else
- change_tr(v_right,mid,right);
- update(v,v_left,v_right);
- }
- }
- public:
- seg_tree(vector<ull>&v):tree(isz(v)<<2,0),arr(v),num(isz(v)<<2,0){
- build(1,0,isz(v));
- }
- void change(ull _pos,ull _x){
- pos=_pos;
- x=_x;
- change_tr(1,0,isz(arr));
- }
- pair<ull,ull> get(ull _start, ull _end){
- clear(0);
- start=_start;
- end=_end+1;
- get_tr(1,0,isz(arr));
- return {tree[0],num[0]};
- }
- };
- int main() {
- ios::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- ull n,m;
- cin>>n>>m;
- vector<ull>v(n);
- forx(i,0,n)
- cin>>v[i];
- seg_tree tr(v);
- forx(i,0,m){
- ull a,b,c;
- cin>>a>>b>>c;
- if(a==1)
- tr.change(b,c);
- else {
- auto res=tr.get(b, c - 1);
- cout << res.first << ' '<<res.second<<'\n';
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment