记录编号 62920 评测结果 AAAAAAAAAA
题目名称 机器调度 最终得分 100
用户昵称 GravatarEzoi_XY 是否通过 通过
代码语言 Pascal 运行时间 0.009 s
提交时间 2013-07-11 19:46:43 内存使用 0.30 MiB
显示代码纯文本
Program cog1168;
    Var
        H,N,E:Array[1..12010]Of Longint;
        M:Array[1..210]Of Longint;
        V:Array[1..210]Of Boolean;
        T,I,J,K,A,B,S:Longint;
    Procedure Ins(A,B:Longint);
        Begin
            Inc(T);
            N[T]:=H[A];
            E[T]:=B;
            H[A]:=T;
        End;
    Function Hungary(I:Longint):Boolean;
        Var
            J:Longint;
        Begin
            J:=H[I];
            While J<>0 Do
                Begin
                    If Not V[E[J]] Then
                        Begin
                            V[E[J]]:=True;
                            If (M[E[J]]=0) Or (Hungary(M[E[J]])) Then
                                Begin
                                    M[E[J]]:=I;
                                    Exit(True);
                                End;
                        End;
                    J:=N[J];
                End;
            Exit(False);
        End;
    Begin
        Assign(Input,'machine.in');
        Assign(Output,'machine.out');
        Reset(Input);
        Rewrite(Output);
        Fillchar(H,Sizeof(H),0);
        Fillchar(N,Sizeof(N),0);
        Fillchar(E,Sizeof(E),0);
        Fillchar(M,Sizeof(M),0);
        T:=0;
        S:=0;
        Readln(A,B,K);
        B:=K;
        Repeat
            Dec(K);
            Readln(I,I,J);
            If (I=0) Or (J=0) Then Continue;
            Inc(I);
            Inc(J);
            Ins(I,A+J);
            Ins(A+J,I);
        Until K=0;
        For I:=1 To A Do
            Begin
                Fillchar(V,Sizeof(V),0);
                If Hungary(I) Then Inc(S);
            End;
        Writeln(S);
        Close(Input);
        Close(Output);
    End.