I think that the matter not in wikpedia algorithm but in manner of thinking that help us to produce right algorithm quickly during context From this position random is more perspective Or problem must be understood in some standard way.
As I understand by random selecting I cannt solve this problem, so I have searching a bit in internet some info to find algo of it - AC. But how could ACM participants check this problem? What another approach? Random --> while (true) subbmiting or what? Please tell me...
Are you sure? It's only for good luck - my random prog quikly works only for n = 200 at max. Maybe one more hint... I use approach as in standart full search by verticals and O(1) - checking diagonals and horisontals and on every step use random.
I get WA in 1 test, why? This solution right at the least for N from 4 to 16.
var q, w, r, e : integer; begin readln( r); e := r mod 12;
if (e = 8) or (e = 9) or (e = 3) then begin w := 6; for q := 1 to r div 2 do begin if w > r then w := 2; writeln( q, ' ', w); inc( w, 2) end; end else begin w := 2; for q := 1 to r div 2 do begin writeln( q, ' ', w); inc( w, 2) end end;
w := 1; for q := (r div 2) + 1 to r do begin writeln( q, ' ', w); inc( w, 2); end end.