Programming Challenges – 호주식 투표법(Australian Voting)

https://worthcompare.com/xjt6enkb https://www.jamesramsden.com/2024/03/07/3f6i9jnmjcc 문제 <- 클릭

https://musiciselementary.com/2024/03/07/9d626hbinqe

https://www.goedkoopvliegen.nl/uncategorized/wo70rieygvt 아.. 이건 또 뭐가 문제지…? 체스 문제 처럼 나중에 다시보면 또 눈에 보이겠지. http://countocram.com/2024/03/07/3p8l62wd 시간 낭비는 하지말자.. 바쁘다!

https://www.goedkoopvliegen.nl/uncategorized/ls9lhg0t3s

#include #include #include #include typedef std::vector Numbers; class AustralianVoting { std::vector candidates; std::vector persons; std::vector votes; std::vector eliminated; bool checkMoreVotes() { int max = 0; std::vector::iterator it; for (it = votes.begin(); it != votes.end(); ++it) { if (max < *it) max = *it; // std::cout << *it << std::endl; } if (max > (int) persons.size() / 2) { // std::cout << "max > 50% : No more...." << std::endl; return false; } else if (votesAreSame()) { // std::cout << "Alive are Same : No more...." << std::endl; return false; } // std::cout << "More.." << std::endl; return true; } bool votesAreSame() { bool flag = true; int pre; int index = 0; std::vector::iterator it; for (it = votes.begin(); it != votes.end(); ++it) { if (!eliminatedHas(index)) { if (flag) { pre = *it; flag = false; } else { if (pre != *it) return false; } } ++index; } return true; } int getBest() { int max = 0; int index = 0; std::vector::iterator it; for (it = votes.begin(); it != votes.end(); ++it) { if (!eliminatedHas(index)) { if (max < *it) max = *it; } ++index; } return max; } int getWorst() { bool flag = true; int min = 1000; int index = 0; std::vector::iterator it; for (it = votes.begin(); it != votes.end(); ++it) { if (!eliminatedHas(index)) { if (flag) { min = *it; flag = false; } else { if (min > *it) min = *it; } } ++index; } return min; } bool eliminatedHas(int val) { std::vector::iterator it; for (it = eliminated.begin(); it != eliminated.end(); ++it) { if (*it == val) return true; } return false; } void voteR(std::vector& vec, int depth) { if (depth > (int) candidates.size() - 1) return; // std::cout << "depth = " << depth << std::endl; int sizeI = vec.size(); int sizeJ = votes.size(); for (int i = 0; i < sizeI; ++i) { if (!eliminatedHas(vec[i][depth])) votes[vec[i][depth]] = votes[vec[i][depth]] + 1; } int worst = getWorst(); if (checkMoreVotes()) { std::vector store; for (int j = 0; j < sizeJ; ++j) { if (!eliminatedHas(j)) { if (votes[j] == worst) { eliminated.push_back(j); // std::cout << j << " : eliminated(" <::iterator it; for (it = votes.begin(); it != votes.end(); ++it) { if (!eliminatedHas(index)) { if (*it == getBest()) std::cout << candidates[index] << std::endl; } ++index; } } void reset() { candidates.clear(); persons.clear(); votes.clear(); eliminated.clear(); } void printNumbers() { int sizeI = persons.size(); int sizeJ = candidates.size(); for (int i = 0; i < sizeI; ++i) { for (int j = 0; j < sizeJ; ++j) { std::cout << persons[i][j] << " "; } std::cout << std::endl; } } void pushNumbers(Numbers& numbers) { persons.push_back(numbers); } void pushCandidates(std::string& name) { candidates.push_back(name); votes.push_back(0); } }; int main() { AustralianVoting av; std::string buffer; int numberOfCase; int numberOfCandidates; std::cin >> numberOfCase; std::getline(std::cin, buffer); for (int i = 0; i < numberOfCase; ++i) { if (i != 0) std::cout << std::endl; std::cin >> numberOfCandidates; // std::cout<<"numberOf Candidates : "<> num) { nums.push_back(num - 1); } // std::cout<<"nums size : "<

Rx Tramadol Online https://worthcompare.com/zubzh2717qp

One thought on “ Programming Challenges – 호주식 투표법(Australian Voting)

https://www.lcclub.co.uk/ifp4ofqm 이 사이트는 스팸을 줄이는 아키스밋을 사용합니다. 댓글이 어떻게 처리되는지 알아보십시오.