Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

匈牙利党飘过

Posted by lql_accept at 2009-11-13 12:56:22 on Problem 2771
var sex:array[1..500]of char;
    sport,music:array[1..500]of string;
    h,pre,num:array[1..500]of longint;
    a:array[1..500,1..500]of longint;
    t:array[1..500]of boolean;
    m1,m2,ii,tt,i,j,n,c,m:longint;
    s:string;
    ch:char;
function find(x:longint):boolean;
  var i:longint;
 begin
  for i:=1 to num[x] do
   if not t[a[x,i]] then begin
    t[a[x,i]]:=true;
    if (pre[a[x,i]]=0)or find(pre[a[x,i]]) then begin
     pre[a[x,i]]:=x; exit(true);
    end;
   end;
  exit(false);
 end;
begin
 readln(tt);
 for ii:=1 to tt do begin
  readln(n);
  for i:=1 to n do begin
   read(ch);
   s:='';
   while ch<>' ' do begin
    s:=s+ch; read(ch);
   end;
   val(s,h[i],c);
   read(sex[i]);
   read(ch); read(ch);
   s:='';
   while ch<>' ' do begin
    s:=s+ch; read(ch);
   end;
   music[i]:=s;
   readln(sport[i]);
  end;
  m1:=0;
  fillchar(num,sizeof(num),0);
  fillchar(pre,sizeof(pre),0);
  for i:=1 to n do
   if sex[i]='M' then begin
    inc(m1);
    m2:=0;
    for j:=1 to n do
     if sex[j]='F' then begin
      inc(m2);
      if (abs(h[i]-h[j])<=40)and(music[i]=music[j])and(sport[i]<>sport[j]) then
       begin
        inc(num[m1]);
        a[m1,num[m1]]:=m2;
       end;
     end;
   end;
  m:=0;
  for i:=1 to m1 do begin
   fillchar(t,sizeof(t),false);
   if find(i) then inc(m);
  end;
  writeln(n-m);
 end;
end.         

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator