(*
* 2011-06-09 Martin <Martin@Martin-desktop>
*
*)
Program Elo;
Uses
Math;
Const
MaxiN = 9999;
Type
TIndex = Longint;
TMain = Extended;
TFlag = Boolean;
Procedure Swap(Var i, j: TIndex);
Var
Tmp: TIndex;
Begin
Tmp := i;
i := j;
j := Tmp;
End;
Procedure Swap(Var i, j: String);
Var
Tmp: String;
Begin
Tmp := i;
i := j;
j := Tmp;
End;
Function Sig(Const X: TMain): TIndex;
Begin
If abs(X) < 1e-9 then
Begin
Sig := 0;
Exit;
End;
If X < 0 then
Sig := - 1
Else
Sig := 1;
End;
Procedure Solve(Const Id: TIndex);
Const
Tab = Chr(9);
Var
N, M, i, j, Tot, RatedPlayer: TIndex;
Ex, EA, SA, Delta, Average: TMain;
Flag: TFlag;
InFile, OutFile, TestFile: String;
F1, F2, F3: Text;
Ch: Char;
Name, Player: Array[1..MaxiN] of String;
Event, Rating, Number, Diff: Array[1..MaxiN] of TIndex;
Score: Array[1..MaxiN] of TMain;
Function getHash(Const St: String): TIndex;
Var
i: TIndex;
Begin
For i := 1 to Tot do
If St = Name[i] then
Begin
getHash := i;
Exit;
End;
Inc(Tot);
Name[Tot] := St;
Event[Tot] := 0;
Rating[Tot] := 0;
getHash := Tot;
End;
Begin
Str(Id - 1, InFile);
InFile := InFile + '.out';
Assign(F1, InFile);
Reset(F1);
N := 0;
While Not SeekEof(F1) do
Begin
Inc(N);
Name[N] := '';
Read(F1, Ch);
While Not (Ch = ' ') do
Begin
Name[N] := Name[N] + Ch;
Read(F1, Ch);
End;
Readln(F1, Event[N], Rating[N]);
End;
Close(F1);
Str(Id, TestFile);
TestFile := TestFile + '.in';
Assign(F3, TestFile);
Reset(F3);
M := 0;
While Not SeekEof(F3) do
Begin
Inc(M);
Player[M] := '';
Read(F3, Ch);
While (Ch <> ' ') and (Ch <> Tab) do
Begin
Player[M] := Player[M] + Ch;
Read(F3, Ch);
End;
Score[M] := 0;
Flag := False;
Ex := 0;
While Not Eoln(F3) do
Begin
Read(F3, Ch);
If (Ch = '.') or (Ch in ['0'..'9']) then
Begin
If (Ch in ['0'..'9']) then
Begin
If (Flag) then
Begin
Ex := Ex / 10.0;
Score[M] := Score[M] + Ex * (Ord(Ch) - Ord('0'));
End
Else
Score[M] := Score[M] * 10 + Ord(Ch) - Ord('0');
End
Else
Begin
Flag := True;
Ex := 1.0;
End;
End
Else
Begin
Score[M] := 0;
Flag := False;
End;
End;
Readln(F3);
End;
Close(F3);
Tot := N;
For i := 1 to M do
Number[i] := getHash(Player[i]);
RatedPlayer := 0;
For i := 1 to M do
If (Number[i] <= N) then
Inc(RatedPlayer);
If (RatedPlayer <= 1) then
Begin
For i := 1 to M do
* 2011-06-09 Martin <Martin@Martin-desktop>
*
*)
Program Elo;
Uses
Math;
Const
MaxiN = 9999;
Type
TIndex = Longint;
TMain = Extended;
TFlag = Boolean;
Procedure Swap(Var i, j: TIndex);
Var
Tmp: TIndex;
Begin
Tmp := i;
i := j;
j := Tmp;
End;
Procedure Swap(Var i, j: String);
Var
Tmp: String;
Begin
Tmp := i;
i := j;
j := Tmp;
End;
Function Sig(Const X: TMain): TIndex;
Begin
If abs(X) < 1e-9 then
Begin
Sig := 0;
Exit;
End;
If X < 0 then
Sig := - 1
Else
Sig := 1;
End;
Procedure Solve(Const Id: TIndex);
Const
Tab = Chr(9);
Var
N, M, i, j, Tot, RatedPlayer: TIndex;
Ex, EA, SA, Delta, Average: TMain;
Flag: TFlag;
InFile, OutFile, TestFile: String;
F1, F2, F3: Text;
Ch: Char;
Name, Player: Array[1..MaxiN] of String;
Event, Rating, Number, Diff: Array[1..MaxiN] of TIndex;
Score: Array[1..MaxiN] of TMain;
Function getHash(Const St: String): TIndex;
Var
i: TIndex;
Begin
For i := 1 to Tot do
If St = Name[i] then
Begin
getHash := i;
Exit;
End;
Inc(Tot);
Name[Tot] := St;
Event[Tot] := 0;
Rating[Tot] := 0;
getHash := Tot;
End;
Begin
Str(Id - 1, InFile);
InFile := InFile + '.out';
Assign(F1, InFile);
Reset(F1);
N := 0;
While Not SeekEof(F1) do
Begin
Inc(N);
Name[N] := '';
Read(F1, Ch);
While Not (Ch = ' ') do
Begin
Name[N] := Name[N] + Ch;
Read(F1, Ch);
End;
Readln(F1, Event[N], Rating[N]);
End;
Close(F1);
Str(Id, TestFile);
TestFile := TestFile + '.in';
Assign(F3, TestFile);
Reset(F3);
M := 0;
While Not SeekEof(F3) do
Begin
Inc(M);
Player[M] := '';
Read(F3, Ch);
While (Ch <> ' ') and (Ch <> Tab) do
Begin
Player[M] := Player[M] + Ch;
Read(F3, Ch);
End;
Score[M] := 0;
Flag := False;
Ex := 0;
While Not Eoln(F3) do
Begin
Read(F3, Ch);
If (Ch = '.') or (Ch in ['0'..'9']) then
Begin
If (Ch in ['0'..'9']) then
Begin
If (Flag) then
Begin
Ex := Ex / 10.0;
Score[M] := Score[M] + Ex * (Ord(Ch) - Ord('0'));
End
Else
Score[M] := Score[M] * 10 + Ord(Ch) - Ord('0');
End
Else
Begin
Flag := True;
Ex := 1.0;
End;
End
Else
Begin
Score[M] := 0;
Flag := False;
End;
End;
Readln(F3);
End;
Close(F3);
Tot := N;
For i := 1 to M do
Number[i] := getHash(Player[i]);
RatedPlayer := 0;
For i := 1 to M do
If (Number[i] <= N) then
Inc(RatedPlayer);
If (RatedPlayer <= 1) then
Begin
For i := 1 to M do