https://transculturalexchange.org/cbfc38sb39 문제 <- 클릭
https://nedediciones.com/uncategorized/vju4tg6xu
https://www.completerehabsolutions.com/blog/n9dow08m 아.. 이건 또 뭐가 문제지…? 체스 문제 처럼 나중에 다시보면 또 눈에 보이겠지.
시간 낭비는 하지말자.. 바쁘다!
Buy Pfizer Xanax 2Mg #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 : "<
very 재미