"codevs1049"

Source: Internet
Author: User

IDs that are not used are likely to be used by anyone;

And when the match, their ID can also and other people's exchange,

If you cannot determine the relationship between two IDs and two names, the IDs of these two people are unknown.

varW:Array[1.. -,1.. -] ofBoolean;id:Array[1.. -] ofString;nm,ans:Array[1.. -] ofstring;room2,used:Array[1.. -] ofBOOLEAN;R,TR:Array[1.. -] ofLongint; n,i,j,p,tmp:longint;cc:char;ss:string;functionCheckName (s:string): Longint;varI:longint;begin fori:=1  toP Do  ifNm[i]=s Thenexit (i); Inc (P); Nm[p]:=S;checkname:=p;End;functionCheckid (s:string): Longint;varI:longint;begin fori:=1  toN Do  ifId[i]=s Thenexit (i);End;functionDFS (P:longint): boolean;varI:longint;beginifp=0  Thenexit (false); fori:=1  toN Do  ifW[p,i] and  not(Used[i]) Then  beginUsed[i]:=true; if(r[i]=0)orDFS (R[i]) Then   beginR[i]:=p;   Exit (TRUE); End; End;d FS:=false;End;beginreadln (N); fori:=1  toN Do   forj:=1  toN DoW[i,j]:=true; fori:=1  toN-1  DobeginSetLength (Id[i], -); Read (cc); J:=0;  whileCc<>' '  Do  beginInc (J); ID[I][J]:=cc;  Read (CC); End; SetLength (id[i],j);End; Readln (Id[n]); READLN (ss); whileSs<>'Q'  Dobegin   Casess[1] of  'E':beginDelete (ss,1,2); Room2[checkname (ss)]:=true; End; 'L':beginDelete (ss,1,2); Room2[checkname (ss)]:=false; End; 'M':beginDelete (ss,1,2); TMP:=Checkid (ss);  fori:=1  toN Do     if  notRoom2[i] Then     beginW[tmp,i]:=false; Writeln ('del'Tmp' ', i); //DebugEnd; End; End; READLN (ss);End; fori:=1  toN DobeginFillchar (used,sizeof (used),0); DFS (i);End; fori:=1  toN Do  ifR[i]>0  Then  begintr:=R; W[r[i],i]:=false; R[i]:=0; Fillchar (used,sizeof (used),0); ifDFS (Tr[i]) ThenAns[i]:=nm[i]+':???'   ElseAns[i]:=nm[i]+':'+Id[tr[i]]; R:=TR; W[r[i],i]:=true; End; fori:=1  toN-1  Do   forj:=i+1  toN Do   ifANS[I]&GT;ANS[J] Then   beginSS:=Ans[i]; Ans[i]:=Ans[j]; ANS[J]:=SS; End; fori:=1  toN DoWriteln (Ans[i]);End.

"codevs1049"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.