|
|
back to boardHelp!!!Why I got WA??? const MAX = 60; MAXL = 5000; type Arr = array [1 .. MAX, 0 .. MAXL] of integer; var Save : Arr; List : array [1 .. MAXL] of integer; Use : array [1 .. MAXL] of boolean; n, i, a, m : integer; function GCD (ga, gb : integer) : integer; var gt : integer; begin while ga mod gb > 0 do begin gt := ga mod gb; ga := gb; gb := gt; end; Gcd := gb; end; function Judge : boolean; var ji, jj, jt : integer; jb : boolean; begin ji := 1; jb := true; while (ji <= n) and jb do begin if Save [ji, 0] > 1 then begin jt := List [Save [ji, 1]]; for jj := 2 to Save [ji, 0] do jt := GCD (jt, List [Save [ji, jj]]); end else jt := 1; jb := (jt = 1); ji := ji + 1; end; Judge := jb; end; procedure Out; var oi : integer; begin writeln ('YES'); for oi := 1 to m do write (List [oi], ' '); halt; end; procedure Search (st : integer); var si : integer; begin for si := 1 to m do if Use [si] then begin Use [si] := false; List [st] := si; if st < m then Search (st + 1) else if Judge then Out; Use [si] := true; end; end; begin fillchar (Save, sizeof (Save), 0); readln (n, m); for i := 1 to n do Use [i] := true; for i := 1 to m do begin read (a); Save [a, 0] := Save [a, 0] + 1; Save [a, Save [a, 0]] := i; readln (a); Save [a, 0] := Save [a, 0] + 1; Save [a, Save [a, 0]] := i; end; Search (1); writeln ('NO'); end. Stop posting your AC programs to the board! (-) Re: Stop posting your AC programs to the board! (-) But my program is WA!!! |
|
|