-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathCondorcetVoting.cpp
More file actions
69 lines (51 loc) · 1.04 KB
/
CondorcetVoting.cpp
File metadata and controls
69 lines (51 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
class CondorcetVoting {
public:
int winner(vector <string> votes)
{
int i, j;
int ret = -1;
int mini = 10000000;
vector <int> v;
for (i=0; i<votes[0].size(); i++)
v.push_back(0);
for (i=0; i<votes.size(); i++)
{
for (j=0; j<votes[i].size(); j++)
{
v[j] += votes[i][j] - 'a';
}
}
for (i=0; i<v.size(); i++)
{
if (mini > v[i])
{
mini = v[i];
ret = i;
}
}
cout << ret << endl;
sort(v.begin(), v.end());
if (v[0] == v[1])
return -1;
return ret;
}
};
// Powered by FileEdit
// Powered by TZTester 1.01 [25-Feb-2003]
// Powered by CodeProcessor
// Powered by FileEdit
// Powered by TZTester 1.01 [25-Feb-2003]
// Powered by CodeProcessor
// Powered by FileEdit
// Powered by TZTester 1.01 [25-Feb-2003]
// Powered by CodeProcessor