제출 #400110

#제출 시각아이디문제언어결과실행 시간메모리
400110teehandsome다리 (APIO19_bridges)C++17
0 / 100
536 ms3996 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define endl '\n' #define INF 1e9+7 #define all(x) x.begin(),x.end() using namespace std; using namespace __gnu_pbds; using ll=long long; using pii=pair<int,int>; using ppi=pair<int,pii>; using oset=tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>; template<typename T> void _print(vector<T> x) {cerr<<"{"; for(auto e:x) cerr<<e<<","; cerr<<"}";} void _print(pii x) {cerr<<"{"<<x.first<<","<<x.second<<"}";} template<typename T> void _print(T x) {cerr<<x;} void dbg() {cerr<<endl;} template<typename Head,typename... Tail> void dbg(Head H,Tail... T) { _print(H); if(sizeof...(T)) cerr<<","; else cerr<<"\"]"; dbg(T...); } #define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:[\"",dbg(__VA_ARGS__) //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int inf=INF; const int mxn=5e4+10; int n,m,q; vector<int> a; int t[3*mxn]; void build(int v,int tl,int tr) { if(tl==tr) t[v]=a[tl]; else { int mid=(tl+tr)/2; build(2*v,tl,mid); build(2*v+1,mid+1,tr); t[v]=min(t[2*v],t[2*v+1]); } } void update(int v,int tl,int tr,int pos,int val) { if(tl>tr or tl>pos or tr<pos) return; if(tl==tr and tl==pos) t[v]=val; else { int mid=(tl+tr)/2; update(2*v,tl,mid,pos,val); update(2*v+1,mid+1,tr,pos,val); t[v]=min(t[2*v],t[2*v+1]); } } int query(int v,int tl,int tr,int l,int r) { // if(l==1 and r==2) debug(tl,tr); if(tl>tr or tl>r or tr<l) return inf; if(tl>=l and tr<=r) return t[v]; int mid=(tl+tr)/2; int res=inf; res=min(res,query(2*v,tl,mid,l,r)); res=min(res,query(2*v+1,mid+1,tr,l,r)); return res; } void deebug(int v,int tl,int tr) { if(v==1) cout<<"======="<<endl; cout<<"["<<v<<", {"<<tl<<","<<tr<<"}]: "; cout<<t[v]<<endl; if(tl==tr) return; int mid=(tl+tr)/2; deebug(2*v,tl,mid); deebug(2*v+1,mid+1,tr); } int f(int l,int r) { return query(1,0,m-1,l-1,r-2); } int main () { ios::sync_with_stdio(false); cin.tie(0); // freopen("Binput.txt","r",stdin); cin>>n>>m; a.resize(m); for(int i=0;i<m;i++) { int u,v; cin>>u>>v; cin>>a[i]; } build(1,0,m-1); // deebug(1,0,m-1); int q; cin>>q; while(q--) { int t,x,y; cin>>t>>x>>y; if(t==1) { a[x-1]=y; update(1,0,m-1,x-1,y); } else { // deebug(1,0,m-1); int ansL=x,ansR=x; int l=1,r=x-1; while(l<=r) { int mid=(l+r)/2; // debug(mid,x,f(mid,x)); if(f(mid,x)>=y) { ansL=mid; r=mid-1; } else l=mid+1; } l=x+1,r=n; while(l<=r) { int mid=(l+r)/2; if(f(x,mid)>=y) { ansR=mid; l=mid+1; } else r=mid-1; } // debug(ansL,ansR); cout<<(ansR-ansL+1)<<endl; } } }
#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...