forked from sitz/UVa-Online-Judge
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path10903.cpp
96 lines (92 loc) · 1.27 KB
/
10903.cpp
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
86
87
88
89
90
91
92
93
94
95
96
#include <bits/stdc++.h>
using namespace std;
struct game
{
int win;
int loss;
int gm;
};
game P[102];
void Cal(int n, int k)
{
string move1, move2;
int p1, p2, y;
y = k * (n * (n - 1)) / 2;
while (y--)
{
cin >> p1 >> move1 >> p2 >> move2;
if (move1 == "rock")
{
if (move2 == "paper")
{
P[p1].loss++;
P[p1].gm++;
P[p2].win++;
P[p2].gm++;
}
else if (move2 == "scissors")
{
P[p1].win++;
P[p1].gm++;
P[p2].loss++;
P[p2].gm++;
}
}
else if (move1 == "paper")
{
if (move2 == "rock")
{
P[p1].win++;
P[p1].gm++;
P[p2].loss++;
P[p2].gm++;
}
else if (move2 == "scissors")
{
P[p1].loss++;
P[p1].gm++;
P[p2].win++;
P[p2].gm++;
}
}
else
{
if (move2 == "paper")
{
P[p1].win++;
P[p1].gm++;
P[p2].loss++;
P[p2].gm++;
}
else if (move2 == "rock")
{
P[p1].loss++;
P[p1].gm++;
P[p2].win++;
P[p2].gm++;
}
}
}
double x;
for (int i = 1; i <= n; i++)
{
x = (double)P[i].win / (double)P[i].gm;
if (P[i].gm == 0)
printf("-\n");
else
printf("%.3lf\n", x);
P[i].gm = P[i].loss = P[i].win = 0;
}
}
int main()
{
int n, k, g = 0;
while (cin >> n && n)
{
cin >> k;
if (g++)
printf("\n");
Cal(n, k);
}
return 0;
}