1.
/**
     * Angewandte Mathematik, SS11
     * Problem: 10903 - Rock-Paper-Scissors Tournament
     * Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=21page=show_problem&problem=1844
     *
     * @author Pirmin Schneider
     * @author Peter Weis
     * @version 1.0, 24/5/2011
     *
     * Method : Ad-Hoc
     * Status: Accepted
     * Runtime: 2.648
     */

Main.java

import java.util.Scanner;

public class Main {

/**
* Angewandte Mathematik, SS11
* Problem: 10903 - Rock-Paper-Scissors Tournament
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=21&page=show_problem&problem=1844
*
* @author Pirmin Schneider
* @author Peter Weis
* @version 1.0, 24/5/2011
*
* Method : Ad-Hoc
* Status: Accepted
* Runtime: 2.648
*/

// number of players
static int n;

// number of battles for each player
static int k;

// storing each players wins
static int wins[] = new int[100];

// storing each players wins
static int losts[] = new int[100];


public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

// index of the player
int p1;
int p2;

// "weapon" of the player
String w_p1;
String w_p2;

boolean first = true;
boolean going = true;

while (going) {

n = sc.nextInt();

// end of tournament
if (n==0) {
going = false;
break;
}

// print line before a testcase, but not before the first one
if (!first) System.out.println();
first = false;

k = sc.nextInt();

// n players battle each other player k times
int totalGames = (k*n*(n-1))/2;

for (int i=0; i<totalGames; i++) {

p1 = sc.nextInt();
w_p1 = sc.next();

p2 = sc.nextInt();
w_p2 = sc.next();

int winner = battle(w_p1, w_p2);

// store wins and losts
if (winner < 0) {
wins[p1-1]++;
losts[p2-1]++;
}
else if (winner > 0) {
wins[p2-1]++;
losts[p1-1]++;
}
}

print();

// reset
wins = new int[100];
losts = new int[100];

}
}

// returns 0 for draw, 1 if player 1 wins, -1 if player 2 wins
static int battle (String a, String b) {
int winner = 0;

if (a == b) return 0;
else if (a.equals("rock") && b.equals("paper")) return 1;
else if (a.equals("rock") && b.equals("scissors")) return -1;

else if (a.equals("paper") && b.equals("scissors")) return 1;
else if (a.equals("paper") && b.equals("rock")) return -1;

else if (a.equals("scissors") && b.equals("rock")) return 1;
else if (a.equals("scissors") && b.equals("paper")) return -1;

return winner;
}

static double avarageWins (int w, int l) {
return (double)w / (double)(w+l);
}

static void print() {
for (int i=0; i<n; i++) {

if (wins[i] + losts[i] > 0) {
double w = avarageWins(wins[i], losts[i]);
System.out.printf("%1.3f%n", w);
}

else System.out.println("-");

}

}

}