제출 #973087

#제출 시각아이디문제언어결과실행 시간메모리
973087Unforgettablepl다리 (APIO19_bridges)C++17
16 / 100
210 ms4176 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define f first #define s second int tree[131072]; int get(int l,int r){ int ans = INT32_MAX; l+=65536;r+=65536; while(l<=r){ if(l&1)ans=min(ans,tree[l++]); if(r%2==0)ans = min(ans,tree[r--]); l/=2;r/=2; } return ans; } void update(int k,int x){ k+=65536; tree[k] = x; k/=2; while(k){ tree[k] = min(tree[2*k],tree[2*k+1]); k/=2; } } int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int n,m; cin >> n >> m; for(int i=1;i<=m;i++){ int c;cin>>c>>c>>c; update(i,c); } int q; cin >> q; for(int i=1;i<=q;i++){ int type,a,b;cin>>type>>a>>b; if(type==1){ update(a,b); } else { int r = a-1; for(int jump=32768;jump;jump/=2){ if(r+jump>=n)continue; if(get(a,r+jump)>=b)r+=jump; } int l = a; for(int jump=32768;jump;jump/=2){ if(l-jump<1)continue; if(get(l-jump,a-1)>=b)l-=jump; } cout << r-l+2 << '\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...