Общий форумPlease tell me whether vector (0,0,0) and (1,1,1) ( for example ) are independent in Prob 1041 ? Thanks. 71222119 mailto : trungduck@yahoo.com you can have the test cases for this problem from russian website (one of the link in "links" part). as i remember, this problem is just to find maximum matches ! QH@ My program was right for all test cases except this test case : 5 4 1 0 0 0 1 1 0 0 1 1 1 0 1 2 3 0 2 3 4 0 1 1 1 1 1 Why the correct answer is 0 ? I think all 5 vectors are independent so the answer is : 4 1 2 3 4 Can u tell me why ? > you can have the test cases for this problem from russian > website (one of the link in "links" part). > as i remember, this problem is just to find maximum matches > ! > > QH@ cap ghep tim dc fai co so dinh ghep dc la maximum (a[i][j]=0 coi nhu ko co ca.nh ;) ) noi chung ba`i na`y anh cung hoi rua, nen ko tra loi ki dc, em thu xem xet cai DN cua thang Mirzayanov Michael xem the nao ;) QH@ I think this prob doesn't need to uses maximum matches. We just "loa.i bo?" vectors that are not independent. For the rest vector (after "loa.i bo?"), we sort it "tang". Just simple ! I have read the definition of Mirzayanov Michael but I din't understand and it was different from the one I know (I read in "Toan cao cap"). Is there any thing reasons that make the test case : 0 ? > cap ghep tim dc fai co so dinh ghep dc la maximum (a[i][j] =0 > coi nhu ko co ca.nh ;) ) > noi chung ba`i na`y anh cung hoi rua, nen ko tra loi ki dc, > em thu xem xet cai DN cua thang Mirzayanov Michael xem the > nao ;) > > QH@ Of course the vectors are dependend, can't you see that the last column contains only 0? Btw for your previous question. Every matrix that contains the 0 vector has determinant 0 i.e. the vectors are linarly dependend. Vectors a1, a2, ... ,an is not independent iff exist such numbers b1, b2, ... ,bn that: 1) abs(b1)+abs(b2)+ ... +abs(bn)>0 2) a1*b1+a2*b2+ ... +an*bn=0 You are Saratov #3 ? No, I am the member of SaratovSU #3 team :) How is your question connect with defenition of independence? > No, I am the member of SaratovSU #3 team :) > How is your question connect with defenition of > independence? Minkov But could u tell me when will they come back? Or is it allways even? But then why does the problem state that the number of digits won't be "greater than 9" ? Always "timeout expire" ? Would you notice us when 'time out' ? Would you notice us when 'time out' ? Would you notice us when 'time out' ? Would you notice us when 'time out' ? Would you notice us when 'time out' ? Would you notice us when 'time out' ? Would you notice us when 'time out' ? Would you notice us when 'time out' ? Would you notice us when 'time out' ? Would you notice us when 'time out' ? Would you notice us when 'time out' ? IS THERE SOMETHING WRONG WITH THE ONLINE JUDGE? I couldn't. Hic hic if u can, please test it again and answer me. Thank you. I'm a newbie of using c++,who can tell me why my program get crash! #include <iostream.h> #include <string.h> #include <stdlib.h> const long maxn = 10000; const long interval = 600; long block[maxn],i,no,t; char *p,s[20]; void main() { for (i=0;i<maxn;i++) block[i]=0; while (!(cin.eof())) { cin.getline(s,19); if ((strchr(s,'+')==NULL)&&(strchr(s,'.')==NULL)) break; if (!(strchr(s,'+')==NULL)){ p = s; t = atoi(p); for (i=0; i<maxn; i++) if ((block[i]==0)||(t-block[i]>=interval)) break; block[i]=t; i++; cout<<i<<"\n"; } else { p = s; t = atoi(p); p = strchr(s,'.')+1; no = atoi(p); no--; if ((t-block[no]>=interval)||(block[no]==0)) cout<<'- '<<"\n"; else { block[no] = t; cout<<'+'<<"\n"; } } } } Thanks 71222119 Mailto : trungduck@yahoo.com You said that you would get AC that problem in 17th hehe . What word do people use to call a man like you ? Do you know that word in English ? hehe stup you are even a C.H.O.M.A. person ;) Good luck for your future! QH@ 71222119 Mailto : trungduck@yahoo.com I don't know why i am get WA. Admin can you send me any tests and solutions. Anyone can help me find the errors: {I use dynamic programming} Program ACM1018; Const max=100; Var n,q,t:byte; qhd:array[0..max,0..max] of longint; mg1:array[0..100] of record rank,n1,n2:byte;app:integer;end; mg:array[1..100] of record i,j:byte;k:integer;end;
Procedure readin; Var i,count:byte; Begin Readln(n,q);if q=n then q:=n-1; For i:=1 to n-1 do begin readln(mg[i].i,mg[i].j,mg[i].k); end; {********} count:=n-1;t:=1; fillchar(mg1,sizeof(mg1),0);mg1[1].rank:=1; Repeat For i:=1 to n-1 do begin if (mg1[mg[i].i].rank=t) and (mg1[mg [i].j].rank=0) then begin if mg1[mg[i].i].n1=0 then mg1[mg [i].i].n1:=mg[i].j else if mg1 [mg[i].i].n2=0 then mg1[mg[i].i].n2:=mg[i].j; mg1[mg[i].j].app:=mg[i].k; mg1[mg[i].j].rank:=t+1;dec (count); end; if (mg1[mg[i].j].rank=t) and (mg1[mg [i].i].rank=0) then begin if mg1[mg[i].j].n1=0 then mg1[mg [i].j].n1:=mg[i].i else if mg1 [mg[i].j].n2=0 then mg1[mg[i].i].n2:=mg[i].i; mg1[mg[i].i].app:=mg[i].k; mg1[mg[i].i].rank:=t+1;dec (count); end; end; inc(t); Until count=0; End; Procedure dynamic; Var i,j,k,l,m:byte;temp:longint; Begin fillchar(qhd,sizeof(qhd),0); For i:=t downto 1 do Begin For j:=1 to n do if mg1[j].rank=i then begin if mg1[j].n1=0 then begin qhd[j,1]:=mg1 [j].app;qhd[j,0]:=1;end else begin qhd[j,1]:=mg1[j].app;qhd[j,0]:=1; if qhd[mg1[j].n1,0]>0 then For k:=1 to qhd[mg1[j].n1,0] do begin if qhd[j,k+1]<qhd[mg1 [j].n1,k]+mg1[j].app then qhd[j,k+1]:=qhd[mg1[j].n1,k]+mg1 [j].app; if k+1>qhd[j,0] then qhd [j,0]:=k+1; if qhd[mg1[j].n2,0]>0 then For l:=1 to qhd[mg1[j].n2,0] do begin if qhd[j,l+1]<qhd [mg1[j].n2,l]+mg1[j].app then qhd[j,l+1]:=qhd[mg1[j].n2,l] +mg1[j].app; if l+1>qhd[j,0] then qhd[j,0]:=l+1; m:=k+l+1; if m>qhd[j,0] then qhd[j,0]:=m; temp:=qhd[mg1 [j].n1,k]+qhd[mg1[j].n2,l]+mg1[j].app; if qhd[j,m]<temp then qhd[j,m]:=temp; end; end; if qhd[j,0]>q-mg1[j].rank+2 then qhd [j,0]:=q-mg1[j].rank+2; if qhd[j,0]<0 then qhd[j,0]:=0; end; end; End; End; Begin readin; dynamic; writeln(qhd[1,q+1]); End. I don't know why i am get WA. Admin can you send me any tests and solutions. Anyone can help me find the errors: {I use dynamic programming} Program ACM1018; Const max=100; Var n,q,t:byte; qhd:array[0..max,0..max] of longint; mg1:array[0..100] of record rank,n1,n2:byte;app:integer;end; mg:array[1..100] of record i,j:byte;k:integer;end;
Procedure readin; Var i,count:byte; Begin Readln(n,q);if q=n then q:=n-1; For i:=1 to n-1 do begin readln(mg[i].i,mg[i].j,mg[i].k); end; {********} count:=n-1;t:=1; fillchar(mg1,sizeof(mg1),0);mg1[1].rank:=1; Repeat For i:=1 to n-1 do begin if (mg1[mg[i].i].rank=t) and (mg1[mg [i].j].rank=0) then begin if mg1[mg[i].i].n1=0 then mg1[mg [i].i].n1:=mg[i].j else if mg1 [mg[i].i].n2=0 then mg1[mg[i].i].n2:=mg[i].j; mg1[mg[i].j].app:=mg[i].k; mg1[mg[i].j].rank:=t+1;dec (count); end; if (mg1[mg[i].j].rank=t) and (mg1[mg [i].i].rank=0) then begin if mg1[mg[i].j].n1=0 then mg1[mg [i].j].n1:=mg[i].i else if mg1 [mg[i].j].n2=0 then mg1[mg[i].i].n2:=mg[i].i; mg1[mg[i].i].app:=mg[i].k; mg1[mg[i].i].rank:=t+1;dec (count); end; end; inc(t); Until count=0; End; Procedure dynamic; Var i,j,k,l,m:byte;temp:longint; Begin fillchar(qhd,sizeof(qhd),0); For i:=t downto 1 do Begin For j:=1 to n do if mg1[j].rank=i then begin if mg1[j].n1=0 then begin qhd[j,1]:=mg1 [j].app;qhd[j,0]:=1;end else begin qhd[j,1]:=mg1[j].app;qhd[j,0]:=1; if qhd[mg1[j].n1,0]>0 then For k:=1 to qhd[mg1[j].n1,0] do begin if qhd[j,k+1]<qhd[mg1 [j].n1,k]+mg1[j].app then qhd[j,k+1]:=qhd[mg1[j].n1,k]+mg1 [j].app; if k+1>qhd[j,0] then qhd [j,0]:=k+1; if qhd[mg1[j].n2,0]>0 then For l:=1 to qhd[mg1[j].n2,0] do begin if qhd[j,l+1]<qhd [mg1[j].n2,l]+mg1[j].app then qhd[j,l+1]:=qhd[mg1[j].n2,l] +mg1[j].app; if l+1>qhd[j,0] then qhd[j,0]:=l+1; m:=k+l+1; if m>qhd[j,0] then qhd[j,0]:=m; temp:=qhd[mg1 [j].n1,k]+qhd[mg1[j].n2,l]+mg1[j].app; if qhd[j,m]<temp then qhd[j,m]:=temp; end; end; if qhd[j,0]>q-mg1[j].rank+2 then qhd [j,0]:=q-mg1[j].rank+2; if qhd[j,0]<0 then qhd[j,0]:=0; end; end; End; End; Begin readin; dynamic; writeln(qhd[1,q+1]); End. Hehe what question ? I'll answer it for you. About 1018, admins here couldn't find their errors so that they didn't answer. That's all. Where is your 1107 solution ? Kimdung - DSAP Group Petko Minkov got it. [1] 20 июн 2001 02:36 Aaah , now i know why :)). BTW excuse me for wasting space with my stoopid previous message ;] > Aaah , now i know why :)). > BTW excuse me for wasting space with my stoopid previous > message ;] > So do I. Kim Dung DSAP Group |
|