Submission #1119031

#TimeUsernameProblemLanguageResultExecution timeMemory
1119031PagodePaivaBridges (APIO19_bridges)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; const int N = 200010; int v[N]; struct Segtree{ int tree[4*N]; int join(int a, int b){ return min(a, b); } void build(int node, int l, int r){ if(l == r){ tree[node] = v[l]; return; } int mid = (l+r)/2; build(2*node, l, mid); build(2*node+1, mid+1, r); tree[node] = join(tree[2*node], tree[2*node+1]); } void udpate(int node, int l, int r, int pos, int val){ if(l == r){ tree[node] = val; return; } int mid = (l+r)/2; if(l <= pos and pos <= mid) update(2*node, l, mid, pos, val); else update(2*node+1, mid+1, r, pos, val); tree[node] = join(tree[2*node], tree[2*node+1]); return; } int query(int node, int l, int r, int tl, int tr){ if(l > tr or tl > r) return 1e9+1; if(l <= tl and tr <= r) return tree[node]; int mid = (tl+tr)/2; return join(query(2*node, l, r, tl,mid), query(2*node+1, l, r, mid+1, tr)); } } seg; int main(){ ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; for(int i = 0;i < m;i++){ int a, b, w; cin >> a >> b >> w; v[i+1] = w; } seg.build(1, 1, n-1); int q; cin >> q; while(q--){ int t; cin >> t; if(t == 1){ int s, w; cin >> s >> w; seg.update(1, 1, n-1, s, w); } else{ int s, w; cin >> s >> w; int l = 1, r = s-1; int ans = s; while(l <= r){ int mid = (l+r)/2; int val = seg.query(1, mid, s-1, 1, n-1); if(val < w){ l = mid+1; } else{ ans = mid; r = mid-1; } } l = s; r = n-1; int ans2 = s; while(l <= r){ int mid = (l+r)/2; int val = seg.query(1, s, mid, 1, n-1); if(val < w){ r = mid-1; } else{ ans = mid; l = mid+1; } } cout << ans2-ans+1 << '\n'; } } }

Compilation message (stderr)

bridges.cpp: In member function 'void Segtree::udpate(int, int, int, int, int)':
bridges.cpp:29:37: error: 'update' was not declared in this scope; did you mean 'udpate'?
   29 |         if(l <= pos and pos <= mid) update(2*node, l, mid, pos, val);
      |                                     ^~~~~~
      |                                     udpate
bridges.cpp:30:14: error: 'update' was not declared in this scope; did you mean 'udpate'?
   30 |         else update(2*node+1, mid+1, r, pos, val);
      |              ^~~~~~
      |              udpate
bridges.cpp: In function 'int main()':
bridges.cpp:60:17: error: 'struct Segtree' has no member named 'update'; did you mean 'udpate'?
   60 |             seg.update(1, 1, n-1, s, w);
      |                 ^~~~~~
      |                 udpate