제출 #250192

#제출 시각아이디문제언어결과실행 시간메모리
250192jeqcho다리 (APIO19_bridges)C++17
0 / 100
73 ms6904 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef vector<int> vi; typedef vector<pair<int,int>> vpi; #define FOR(i,a,b) for (int i = (a); i < (b); ++i) #define F0R(i,a) FOR(i,0,a) #define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i) #define R0F(i,a) ROF(i,0,a) #define trav(a,x) for (auto& a: x) #define pb push_back #define rsz resize #define sz(x) int(x.size()) #define all(x) begin(x), end(x) #define f first #define s second int n,m; vector<long long> seg; int arr_sz; // sum 0 // min 1e9+3 // max -(1e9+3) int init_value = -(1e9+3); int tree_level; ll build(int idex, int lx, int rx) { if(lx==rx-1)return seg[idex]; // Operation specific seg[idex] = min(build(2*idex+1, lx,(lx+rx)/2 ), build(2*idex+2, (lx+rx)/2,rx)); return seg[idex]; } void update(int idex, int val) { idex += arr_sz-1; seg[idex] = val; --idex; while(idex>=0) { idex /= 2; // Operation specific seg[idex] = min(seg[2*idex+1], seg[2*idex+2]); --idex; } } tuple<ll,bool,bool> minq(int idex, int start_node, int lx, int rx, int w) { if(seg[idex]>w) { if(lx==rx-1)return {0,0,0}; tuple<ll,bool,bool> lef,rig,ans={0,0,0}; lef = minq(2*idex+2,start_node, (lx+rx)/2,rx, w); rig = minq(2*idex+2,start_node,lx,(lx+rx)/2, w); if(start_node < (lx+rx)/2) { if(!get<2>(lef)) { rig={0,0,0}; } else { if(!get<1>(rig))rig={0,0,0}; } } else { if(!get<1>(rig)) { lef={0,0,0}; } else { if(!get<2>(lef))lef={0,0,0}; } } bool lok = get<1>(lef)&&get<2>(lef); bool rok = get<1>(rig)&&get<2>(rig); return {get<0>(lef)+get<0>(rig), lok,rok}; } else { // return number of elements in segment return {rx-lx+1,1,1}; } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin>>n>>m; int u,v,d; int p2 = ceil(log2((long double)m)); // power 0 is level 0 tree_level = p2+1; arr_sz = 1<<p2; int tree_sz = 2*arr_sz; seg.rsz(tree_sz); fill(all(seg),init_value); F0R(i,m) { cin>>u>>v>>d; seg[arr_sz-1 + i]=d; } build(0,0,arr_sz); int q; cin>>q; int typ, bj, rj, sj, wj; while(q--) { cin>>typ; if(typ==1) { cin>>bj>>rj; --bj; update(bj,rj); } else { cin>>sj>>wj; --sj; cout<<get<0>(minq(0,sj,0,arr_sz, wj))<<'\n'; } } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

bridges.cpp: In function 'std::tuple<long long int, bool, bool> minq(int, int, int, int, int)':
bridges.cpp:59:37: warning: variable 'ans' set but not used [-Wunused-but-set-variable]
         tuple<ll,bool,bool> lef,rig,ans={0,0,0};
                                     ^~~
#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...