Submission #977472

#TimeUsernameProblemLanguageResultExecution timeMemory
977472dubabubaBridges (APIO19_bridges)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int mxn = 2e5 + 10; int n, m, q, a[mxn], st[mxn * 4]; void build(int id, int tl, int tr) { if(tl == tr) { st[id] = a[tl]; return; } int tm = (tl + tr) / 2; build(id * 2 + 1, tl, tm); build(id * 2 + 2, tm + 1, tr); st[id] = min(st[id * 2 + 1], st[id * 2 + 2]); } int query(int id, int tl, int tr, int i, int low) { if(st[id] > low) return tr - tl + 1; if(tl == tr) return 0; int tm = (tl + tr) / 2; if(i <= tm) { int LQ = query(id * 2 + 1, tl, tm, i, low); int RQ = 0; if(LQ == tm - tl + 1) RQ = query(id * 2 + 2, tm + 1, tr, tm + 1, low); return LQ + RQ; } int LQ = 0; int RQ = query(id * 2 + 2, tm + 1, tr, i, low); if(RQ == tr - tm) LQ = query(id * 2 + 1, tl, tm, tm, low); return LQ + RQ; } int main() { cin >> n >> m; for(int i = 0; i < m; i++) { int u, v, w; cin >> u >> v >> w; a[i] = w; } build(0, 0, m - 1); cin >> q; for(int i = 0; i < q; i++) { int t, s, w; cin >> t >> s >> w; if(t == 1) upt(0, 0, m - 1, s - 1, w); else { pii L = s < 2 ? (-1, -1) : (s - 2, a[s - 2]); pii R = s < n ? (s - 1, a[s - 1]) : (-1, -1); pii P = max(L, R); cout << query(0, 0, m - 1, P.ss, w); } } return 0; }

Compilation message (stderr)

bridges.cpp: In function 'int main()':
bridges.cpp:53:14: error: 'upt' was not declared in this scope
   53 |   if(t == 1) upt(0, 0, m - 1, s - 1, w);
      |              ^~~
bridges.cpp:55:4: error: 'pii' was not declared in this scope
   55 |    pii L = s < 2 ? (-1, -1) : (s - 2, a[s - 2]);
      |    ^~~
bridges.cpp:56:7: error: expected ';' before 'R'
   56 |    pii R = s < n ? (s - 1, a[s - 1]) : (-1, -1);
      |       ^~
      |       ;
bridges.cpp:57:7: error: expected ';' before 'P'
   57 |    pii P = max(L, R);
      |       ^~
      |       ;
bridges.cpp:59:31: error: 'P' was not declared in this scope
   59 |    cout << query(0, 0, m - 1, P.ss, w);
      |                               ^