Submission #252364

#TimeUsernameProblemLanguageResultExecution timeMemory
252364khangalBridges (APIO19_bridges)C++14
0 / 100
235 ms199288 KiB
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; typedef long long ll; typedef double db; typedef vector<long long> vl; typedef pair<long long , long long > pl; const int N=1e6+1; #define po pop_back #define pb push_back #define mk make_pair #define lw lower_bound #define up upper_bound #define ff first #define ss second #define boost ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0); #define MOD 1000000007 #define MAX 1e18 #define MIN -1e18 #define rep(i,a,b) for(ll i=a;i<=b;i++) #define per(i,a,b) for(ll i=b;i>=a;i--) #define con continue #define freopen freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout); #define PI 3.14159265358979323846264338327950288419716939937510582097494459230781640628 // typedef tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set; // template< typename T> // using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; ll n,m,ans,mid,mn,mx,cnt,T,sum,h1,h2,e[1234567],b[1234567],c[1234567],d[1<<20],k,i,j,l,h,a[1234567],w; ll x[1234567],y[1234567],z[1234567]; bool used[1234567],used1[1234567]; pl p[1234567]; string s,s1[1234567]; map<ll,ll> mp; map<pl,ll> mpl; vector<pl> vec,vec1,ansvec; vector<ll> v[1234567],v1[1234567]; vector<ll> vp[1234567]; set<ll> st; stack <ll> sta; set<ll> c1[1234][1234]; ll tr[1234567]; void build(ll node,ll l,ll r){ if(l==r){ tr[node]=e[l]; return; } ll mid=(l+r)/2; build(node*2 , l , mid); build(node*2+1 , mid+1 , r); tr[node] = min(tr[node*2] , tr[node*2+1]); } void update(ll node,ll l,ll r,ll k,ll val){ if(l == r){ tr[node]=val; return; } ll mid = (l+r)/2; if(k <= mid) update(node*2,l,mid,k,val); else update(node*2+1,mid+1,r,k,val); tr[node] = min(tr[node*2],tr[node*2+1]); } ll query(ll node,ll l,ll r,ll L,ll R){ if(L <= l && R >= r) return tr[node]; ll mid = (l+r)/2; if(L <= mid && R > mid){ return min(query(node*2,l,mid,L,R),query(node*2+1,mid+1,r,L,R)); } if(L <= mid) return query(node*2,l,mid,L,R); return query(node*2+1,mid+1,r,L,R); } ll search1(ll node,ll val){ ll l = node,r = n; while(r-l > 1){ if(query(1,0,n-2,node,mid-1) >= val) l = mid; else r = mid; } return l-node; } ll search2(ll node,ll val){ ll l = -1,r = node; while(r-l > 1){ if(query(1,0,n-2,mid,node-1) >= val) r = mid; else l = mid; } return node-r; } int main(){ cin>>n>>m; rep(i,1,m){ ll a,b,c; cin>>a>>b>>c; e[i]=c; } rep(i,m+1,2*n)e[i]=MAX; build(1,1,n); //rep(i,1,2*n)cout<<tr[i]<<" "; rep(i,1,k){ ll x,y,z; cin>>x>>y>>z; if(x==1){ update(1,1,n,y,z); } else{ cout<<search1(y,z) + search2(y,z)-1<<'\n'; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...