| 19 | public class Code07_HideSeek1 { |
| 20 | |
| 21 | static class Set { |
| 22 | PriorityQueue<Integer> addHeap; |
| 23 | PriorityQueue<Integer> delHeap; |
| 24 | |
| 25 | public Set() { |
| 26 | addHeap = new PriorityQueue<>((a, b) -> b.compareTo(a)); |
| 27 | delHeap = new PriorityQueue<>((a, b) -> b.compareTo(a)); |
| 28 | } |
| 29 | |
| 30 | void clean() { |
| 31 | while (!delHeap.isEmpty() && delHeap.peek().equals(addHeap.peek())) { |
| 32 | addHeap.poll(); |
| 33 | delHeap.poll(); |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | int popHead() { |
| 38 | int ans = addHeap.poll(); |
| 39 | clean(); |
| 40 | return ans; |
| 41 | } |
| 42 | |
| 43 | int size() { |
| 44 | return addHeap.size() - delHeap.size(); |
| 45 | } |
| 46 | |
| 47 | void add(int v) { |
| 48 | addHeap.add(v); |
| 49 | } |
| 50 | |
| 51 | void del(int v) { |
| 52 | delHeap.add(v); |
| 53 | clean(); |
| 54 | } |
| 55 | |
| 56 | int first() { |
| 57 | return addHeap.peek(); |
| 58 | } |
| 59 | |
| 60 | int second() { |
| 61 | int a = popHead(); |
| 62 | int b = first(); |
| 63 | add(a); |
| 64 | return b; |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | public static int MAXN = 100001; |
| 69 | public static int n, m; |
nothing calls this directly
no outgoing calls
no test coverage detected