void GLWidget::rangeSearch(TwoDTree::Node *p, RangeQuery &rq, std::vector<QPointF> &includingPoints) { if (p != nullptr) { double l; double r; double coord; if (p->isVertical) { l = qMin(rq.p2.y(), rq.p1.y()); r = qMax(rq.p2.y(), rq.p1.y()); coord = p->value.y(); } else { l = qMin(rq.p2.x(), rq.p1.x()); r = qMax(rq.p2.x(), rq.p1.x()); coord = p->value.x(); } if (p->value.y() <= getHighest(rq) && p->value.y() >= getLowest(rq) && p->value.x() >= getLeftMost(rq) && p->value.x() <= getRightMost(rq)) { includingPoints.push_back(p->value); } if (l < coord) { rangeSearch(p->left, rq, includingPoints); } if (r > coord) { rangeSearch(p->right, rq, includingPoints); } } }
int main() { //ROP; int n, m; scanf("%d%d", &n, &m); while (m--) { int u, v; scanf("%d%d", &u, &v); --u; --v; mp[u][v] = mp[v][u] = true; } for (int i = 0; i < n; ++i) dp[1<<i][i] = 1; LL ans = 0; for (int s = 0; s < (1 << n); ++s) { int lowestPoint = getLowest(s); for (int end = 0; end < n; ++end) if ((s & (1 << end)) && dp[s][end]) { for (int to = lowestPoint; to < n; ++to) if (mp[end][to]) { if (s & (1 << to)) { if ((1 << to | 1 << end) == s) continue; if (to == lowestPoint) ans += dp[s][end]; } else { dp[s | (1 << to)][to] += dp[s][end]; } } } } printf("%I64d\n", ans/2); return 0; }
bool PokerHandEvaluator::isStraight() { if (pairCount() > 0) return false; Rank lowest = getLowest(); for (std::list<Card>::iterator it = cards.begin(); it != cards.end(); ++it) { Rank cardRank = it->getRank(); for (std::list<Card>::iterator it2 = cards.begin(); it2 != cards.end(); ++it2) { } } }
int main() { do { string fileName = getFileName(); vector<int> numberArray; initializeArray(fileName, numberArray); cout << "The lowest number is: " << getLowest(numberArray) << endl; cout << "The highest number is: " << getHighest(numberArray) << endl; cout << "The sum of all these numbers is: " << getSum(numberArray) << endl; cout << "The average of all these numbers is: " << setprecision(10) << fixed << getAverage(numberArray) << endl; } while (!wantToExit()); return 0; }
vector<int> CSVop::getLowestrows(vector<int> rows, int col, double precision, bool absolute) { double maxval; maxval = getLowest(col, rows); return getrowswtol(rows, col, maxval, precision, absolute); }
neighbourList* aStarPathFinder(node* f_startNode_pst, node* f_endNode_pst) { int32 unitGscore_i32 = 1; int32 gScoreStart_i32 = 0; int32 hScoreStart_i32; aStarNode* startAStarNode = createAStarNode(f_startNode_pst); aStarNode* startCameFrom_pst = NULL; aStarList* openAStarList_pst = createAStarList(); aStarList* closedAStarList_pst = createAStarList(); if(startAStarNode && openAStarList_pst && closedAStarList_pst) { hScoreStart_i32 = heuristicEstimate(f_startNode_pst, f_startNode_pst, f_endNode_pst); setAllInfoAStarNode(startAStarNode, f_startNode_pst, startCameFrom_pst, gScoreStart_i32, hScoreStart_i32); addToEndAStarList(openAStarList_pst, startAStarNode); while(!isAStarListEmpty(openAStarList_pst)) { aStarNode* LowestFscoreNode_pst = getLowest(openAStarList_pst); if (f_endNode_pst == LowestFscoreNode_pst ->informationNode_pst) { // Reconstruct path, destroy the AStarlists created above // and return the node list to process neighbourList* AstarPath_pst = reconstructPath(startAStarNode, LowestFscoreNode_pst); destroyAStarList(openAStarList_pst); destroyAStarList(closedAStarList_pst); return AstarPath_pst; } removeFromAStarList(openAStarList_pst, LowestFscoreNode_pst); addToEndAStarList(closedAStarList_pst, LowestFscoreNode_pst); node* currentNode_pst = LowestFscoreNode_pst ->informationNode_pst; neighbourList* NeighbourList_pst = getNeighbourList(currentNode_pst); if(!isNeighbourListEmpty(NeighbourList_pst)) { neighbourListNode* nextNeighbour_pst = NULL; neighbourListNode* neighbour_pst = NeighbourList_pst->head; for (; neighbour_pst != NULL; neighbour_pst = nextNeighbour_pst) { nextNeighbour_pst = neighbour_pst->next; node* neighbourNode_pst = neighbour_pst ->neighbourNode_pst; if(searchNeighbourInAStarList(closedAStarList_pst, neighbourNode_pst)) { continue; } int32 neighbourGscore_i32 = LowestFscoreNode_pst ->gScore_i32 + unitGscore_i32; aStarListNode* searchResult_pst = searchNeighbourInAStarList(openAStarList_pst, neighbourNode_pst); if (!searchResult_pst) { aStarNode* neighbourAStarNode = createAStarNode(neighbourNode_pst); int32 neighbourHscore_i32 = heuristicEstimate(f_startNode_pst, neighbourNode_pst, f_endNode_pst); setAllInfoAStarNode(neighbourAStarNode, neighbourNode_pst, LowestFscoreNode_pst, neighbourGscore_i32, neighbourHscore_i32); addToEndAStarList(openAStarList_pst, neighbourAStarNode); } else if (neighbourGscore_i32 < searchResult_pst ->aStarNode_pst ->gScore_i32) { aStarNode* neighbourAStarNode = searchResult_pst ->aStarNode_pst; setCameFromPtr(neighbourAStarNode, LowestFscoreNode_pst); setGScore(neighbourAStarNode, neighbourGscore_i32); setFScore(neighbourAStarNode, neighbourGscore_i32, neighbourAStarNode ->hScore_i32); } } } destroyNeighbourList(NeighbourList_pst); } return NULL; } return NULL; }