|
|
вернуться в форумWho can help me?Write to this address:yuyuanming163@163.com Послано Tony 30 сен 2002 15:46 Re: I have got AC!!! Послано Tony 30 сен 2002 17:34 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. But your solution is wrong! 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? Sorry, I didn't read statement carefully: "No three towns lay on one line. " Re: I have got AC!!! Your solution looks so strange! Can you tell me why it works? Re: I have got AC!!! Ha! Very funny! I got it! Oh, yeah!!!!!!!!!!!!! Re: I have got AC!!! Oh, you needn't explain it to me any more. I have understood it! Re: I have got AC!!! bravoooo!!! Your idea is very good. Re: But your solution is wrong! I think this is incorrect test. Because, No three towns lay on one line. |
|
|