Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения | now its me... HELP ME | Edans | 1207. Медиана на плоскости | 30 апр 2002 09:01 | 1 | somebody see a mistake? #define MAXINT 2000000000 #include<stdio.h> #include<math.h> #include<stdlib.h> typedef struct{ int x,y; int ID; double ang; }ponto_t; ponto_t tb[10000]; int sort( const void *a, const void *b){ ponto_t* ta = (ponto_t*)a; ponto_t* tb = (ponto_t*)b; if ((ta->x==0) && (ta->y==0)) return -1; if ((tb->x==0) && (tb->y==0)) return 1; return (ta->x*tb->y - tb->x*ta->y)>0?1:-1; } int main(){ #ifndef ONLINE_JUDGE freopen("1207.in","r",stdin); freopen("1207.out","w",stdout); #endif int n,x=MAXINT,themin=0,k; scanf("%d",&n); for(k=0;k<n;k++){ scanf("%d %d",&(tb[k].x),&(tb[k].y)); tb[k].ID=k+1; if (tb[k].x<x){ x=tb[k].x; themin=k; } } for(k=0;k<n;k++){ tb[k].x-=tb[themin].x; tb[k].y-=tb[themin].y; } qsort(tb,n,sizeof(ponto_t),sort); printf("%d %d",tb[0].ID,tb[n/2].ID); return 0; } | why my solution can't get AC Help me please... (+) | Badd | 1207. Медиана на плоскости | 19 апр 2002 20:21 | 1 | {My solution process by sorting the curve of point and geting the median curve point ... thank} const inp = '1207.in'; maxn= 10005; type tdat = record xx,yy,id : longint; end; var fname : text; dat : array[1..maxn] of tdat; temp : tdat; l,n,l2,min,m,mx,my,i : longint; begin readln(n); min:=maxlongint; for l:=1 to n do begin readln(dat[l].xx,dat[l].yy); if dat[l].xx<min then begin min:=dat[l].xx; m:=l; end; dat[l].id:=l; end; mx:=dat[m].xx; my:=dat[m].yy; i:=dat[m].id; for l:=1 to n-1 do for l2:=l+1 to n do if (my-dat[l2].yy)*(mx-dat[l].xx) > (my-dat[l].yy) *(mx-dat[l2].xx) then begin temp:=dat[l2]; dat[l2]:=dat[l]; dat[l]:=temp; end; for l:=1 to n do if (dat[l].xx=mx) and (dat[l].yy=my) then begin if l>n div 2 then writeln(i,' ',dat[n div 2].id) else writeln(i,' ',dat[(n div 2)+1].id); halt; end; end. | PLease..will someone tell me how to understand why CompError?Here is my source | Vladimir Milenov Vasilev | 1207. Медиана на плоскости | 14 апр 2002 21:14 | 2 | Here is my source.I am using VStudio 6.0 an dit is OK but...I got Compilation Error. How to understand why and what to compile my program with???? #include <stdio.h> long ind,pom,n,x[10000],y[10000],ymin,i,j,xx,yy; int pos[10000]; void main() { scanf("%ld",&n); ymin=1000000000; for (i=0;i<n;i++) { scanf("%ld%ld",&x[i],&y[i]); pos[i]=i; if (ymin>y[i]) { ind=i; ymin=y[i]; } } pom=y[ind]; y[ind]=y[n-1]; y[n-1]=pom; pom=x[ind]; x[ind]=x[n-1]; x[n-1]=pom; xx=x[n-1]; yy=y[n-1]; pos[ind]=n-1; pos[n-1]=ind; for(i=0;i<n-1;i++) for(j=i+1;j<n;j++) if (((float)(x[i]-xx)*(float)(y[j]-yy))- ((float)(x[j]-xx)*(float)(y[i]-yy))>0) { pom=y[i]; y[i]=y[j]; y[j]=pom; pom=x[i]; x[i]=x[j]; x[j]=pom; pom=(long)pos[i]; pos[i]=pos[j]; pos[j]=(int)pom; } printf("%d %d\n",pos[n-1]+1,pos[(int)((n/2)-1)]+1); } This is most probably an internal Timus problem. I sent 5 different tasks and received the same reply yesterday - something like "temp\184951(29) : error C2471: cannot update program database 'e:\judge\vc60.pdb'". So, we should write on Pascal or wait... | Help!Help!Help! Thank you!!! | Fair Rosmarin | 1207. Медиана на плоскости | 8 апр 2002 02:05 | 2 | For a test case: if it should be output " a b ", it also could be output " b a ", which one is correct? for a test case,for example: 4 1 0 0 1 1 1 2 2 we could select not only 1 3, but also 3 4, which is the correct one ? I think, you can take any of them | Who can help me? | zouyi1 | 1207. Медиана на плоскости | 7 апр 2002 15:38 | 3 | If N is a odd number,what's the output? Do you have a input and the answer? > If N is a odd number,what's the output? > Do you have a input and the answer? > If the answer are many,what shall I do? > > If N is a odd number,what's the output? > > Do you have a input and the answer? > > If the answer are many,what shall I do? | What's wrong with my program? Please help | Alyosha Popovich | 1207. Медиана на плоскости | 19 мар 2002 20:35 | 3 | // heapsort the points (graham-like) [code deleted] Edited by moderator 24.11.2019 23:26 > scanf("%d", &N); possibly should be scanf("%ld",&N) int is by default long in 32-bit environment problem is solved anyway (it was the V[i] = ++i statement in the read_data for) thanx anyway |
|
|