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]>ANS[J] Then beginSS:=Ans[i]; Ans[i]:=Ans[j]; ANS[J]:=SS; End; fori:=1 toN DoWriteln (Ans[i]);End.
"codevs1049"