标签:nim pytho put inpu gem void || mini highlight
int rangeMinQuery(int segTree[], int qlow, int qhigh, int low, int high, int pos) { if (qlow <= low && qhigh >= high) return segTree[pos]; if (qlow > high || qhigh < low) return maxVal; int mid = (low + high) / 2; return min(rangeMinQuery(segTree, qlow, qhigh, low, mid, 2*pos+1), rangeMinQuery(segTree, qlow, qhigh, mid+1, high, 2*pos+2)); } void constructTree(int input[], int segTree[], int low, int high, int pos) { if (low == high) { segTree[pos] = input[low]; return; } int mid = (low + high) / 2; constructTree(input, segTree, low, mid, 2*pos+1); constructTree(input, segTree, mid+1, high, 2*pos+2); segTree[pos] = min(segTree[2*pos+1], segTree[2*pos+2]); }
Segment Tree Range Minimum Query.
标签:nim pytho put inpu gem void || mini highlight
原文地址:https://www.cnblogs.com/ruruozhenhao/p/10051343.html