MCPcopy Create free account
hub / github.com/SuprDewd/CompetitiveProgramming / min_queue

Class min_queue

code/data-structures/monotonic_queue.cpp:10–22  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8 void pop() { S.pop(); M.pop(); }
9 bool empty() { return S.empty(); } };
10struct min_queue {
11 min_stack inp, outp;
12 void push(int x) { inp.push(x); }
13 void fix() {
14 if (outp.empty()) while (!inp.empty())
15 outp.push(inp.top()), inp.pop(); }
16 int top() { fix(); return outp.top(); }
17 int mn() {
18 if (inp.empty()) return outp.mn();
19 if (outp.empty()) return inp.mn();
20 return min(inp.mn(), outp.mn()); }
21 void pop() { fix(); outp.pop(); }
22 bool empty() { return inp.empty() && outp.empty(); } };
23// vim: cc=60 ts=2 sts=2 sw=2:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected