|
|
вернуться в форумПоказать все сообщения Спрятать все сообщенияfollow is my program: var a:array[1..10000]of longint; z:array[1..10000]of integer; i,j,k,n:longint; begin fillchar(a,sizeof(a),0); fillchar(z,sizeof(z),0); read(n); for i:=1 to n do begin read(a[i],j);z[i]:=i;end; for i:=1 to n-1 do for j:=i+1 to n do if a[z[i]]>a[z[j]] then begin k:=z[i]; z[i]:=z[j]; z[j]:=k; end; i:=0; while i<n do begin writeln(z[i+1],' ',z[i+2]); inc(i,2); end; end. Try this: 4 1 1 1 3 1 2 1 4 Your program says 1 2 3 4 but those roads intersect. My first solution was wrong also, but I sort towns by polar angle and I can choose center randomly. TO JUDGES: Can you add few tests that catch solutions, which sort towns only by X or by Y? I think this is incorrect test. Because, No three towns lay on one line. Your solution looks so strange! Can you tell me why it works? Oh, you needn't explain it to me any more. I have understood it! Ha! Very funny! I got it! Oh, yeah!!!!!!!!!!!!! bravoooo!!! Your idea is very good. |
|
|