// UVa 10903 - Rock-Paper-Scissors Tournament #include <iostream> #include <string> #include <string.h> #include <map> #include <stdio.h> using namespace std; int main() { int n, k; map<string, int> rank; rank["rock"] = 0; rank["paper"] = 1; rank["scissors"] = 2; int t = 0; while (cin >> n >> k && n) { t++; int won[101], lost[101]; memset(won, 0, sizeof(won)); memset(lost, 0, sizeof(lost)); for (int i = 0; i < k * n * (n - 1) / 2; i++) { int p1, p2; string m1, m2; cin >> p1 >> m1 >> p2 >> m2; if (rank[m1] == rank[m2]) continue; if ((rank[m1] + 1) % 3 == rank[m2]) { won[p2]++; lost[p1]++; } else { won[p1]++; lost[p2]++; } } if (t > 1) cout << endl; for (int i = 1; i <= n; i++) if (won[i] + lost[i] > 0) printf("%.3f\n", won[i] * 1.0 / (won[i] + lost[i])); else cout << "-" << endl; } return 0; }
Thursday, May 14, 2015
UVa 10903 - Rock-Paper-Scissors Tournament
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment