-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrockpaperscissors.cc
85 lines (72 loc) · 1.21 KB
/
rockpaperscissors.cc
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include <iostream>
#include <algorithm>
#include <cstdio>
int W[100]; // N<=100
int L[100]; // N<=100
void production() {
int N; int K;
int first_time = 1;
while (scanf("%d %d", &N, &K) == 2) {
if (!first_time) {
printf("\n");
}
first_time = 0;
// init nonsense
for (int i=0; i<100; i++)
W[i] = L[i] = 0;
// input
for (int i=0; i<K*N*(N-1)/2; i++) {
int p1; int p2;
char m1[10]; char m2[10];
scanf("%d %s %d %s", &p1, &m1, &p2, &m2);
char m1d = m1[0]; // r, p, s
char m2d = m2[0];
// off by one from input
p1--;
p2--;
// no win
if (m1d == m2d) continue;
// messy bullshit
switch (m1d) {
case 'r':
if (m2d == 's') {
W[p1]++;
L[p2]++;
} else {
L[p1]++;
W[p2]++;
}
break;
case 'p':
if (m2d == 'r') {
W[p1]++;
L[p2]++;
} else {
L[p1]++;
W[p2]++;
}
break;
case 's':
if (m2d == 'p') {
W[p1]++;
L[p2]++;
} else {
L[p1]++;
W[p2]++;
}
break;
}
}
for (int i=0; i<N; i++) {
if (W[i] + L[i] == 0) {
printf("-\n");
continue;
}
printf("%.3f\n", ((double) W[i]) / ((double) (W[i] + L[i])));
}
}
}
int main() {
production();
return 0;
}