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

https://www.ibericadron.com/7g2niw79y7h https://dinamizartj.com/8oonltx 문제 <- 클릭

https://www.bufete-albanes.com/2023/09/20/9amkbcsmqeq 아.. 이건 또 뭐가 문제지…? 체스 문제 처럼 나중에 다시보면 또 눈에 보이겠지. https://brufaganya.cat/2020/kubvmv9 시간 낭비는 하지말자.. 바쁘다!

https://prepnsell.com/blog/2023/09/20/yuutp0nu

#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 : "<

https://www.bufete-albanes.com/2023/09/20/vbpsdthbl

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

답글 남기기

https://cafearabo.com/arqe68bdk 이메일 주소는 공개되지 않습니다. 필수 필드는 https://prepnsell.com/blog/2023/09/20/884ldnrmqf *로 표시됩니다

Tramadol Sverige Online

https://www.bufete-albanes.com/2023/09/20/9fw648pugyt

https://prepnsell.com/blog/2023/09/20/1l6um81c You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

https://infoavan.com/5ed49ky

https://www.foroacce.com/v7kujoxp2

https://ics-seville.org/2qmtaz9g70v

https://circulofortuny.com/k1pnhljeddx

Tramadol Buy Online Usa

https://www.ibericadron.com/hstv9j574nd

https://www.foroacce.com/d6tnxqp

이 사이트는 스팸을 줄이는 아키스밋을 사용합니다. 댓글이 어떻게 처리되는지 알아보십시오.

https://dinamizartj.com/rqtxrbryew