Общий форум| Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения | | Will someone help me. I dont know what does it mean "Crash" | Vladimir Milenov Vasilev | | 8 июл 2001 13:03 | 2 | Here is my program It always gets CRASH? Could you tell me why, please? program staircase; const max=500; var n,i,j:longint; a:array[0..max,0..max]of real; procedure br(n:integer); var i,j:integer; begin for i:=1 to n do for j:=1 to n do if j=1 then a[i,j]:=0 else if (j*(j+1)div 2)<i then a[i,j]:=0 else if j=i then a[i,j]:=1+a[j,j-1] else if (j=i-1)then a[i,j]:=1+a[i,j-1] else if j>i then a[i,j]:=a[i,i] else a[i,j]:=a[i-j,j-1]+a[i,j-1]; end; begin readln(n); br(n); writeln(round(a[n,n]-1)); end. Thank you! > Here is my program > It always gets CRASH? > Could you tell me why, please? > > program staircase; > const max=500; > var n,i,j:longint; > a:array[0..max,0..max]of real; > procedure br(n:integer); > var i,j:integer; > begin > for i:=1 to n do > for j:=1 to n do > if j=1 then a[i,j]:=0 > else if (j*(j+1)div 2)<i then a[i,j]:=0 > else if j=i then a[i,j]:=1+a[j,j-1] > else if (j=i-1)then a[i,j]:=1+a[i,j-1] > else if j>i then a[i,j]:=a[i,i] > else a[i,j]:=a[i-j,j-1]+a[i,j-1]; > end; > begin > readln(n); > br(n); > writeln(round(a[n,n]-1)); > end. > > > Thank you! > > | | Prob 1090 "In the army now" : I know its algorithm is "Balanced tree" but is there any other algorithm run in time limit ? | Tran Nam Trung (trungduck@yahoo.com) | | 7 июл 2001 18:47 | 2 | 71222119 mailto : trungduck@yahoo.com Yes there is much simpler algorithm for this problem, just use array [1..10000] and do binary search on it. Use the elements of the array to denote how many times you have gone left of them(during the binary search). You should do this sequentialy for every element in the input, and you'll get n * log 10000 algorithm. | | why did my program get WA? | The Answer | 1019. Перекрашивание прямой | 7 июл 2001 17:53 | 1 | My program pass every test data which were designed by myself. I want to know if there are some special test data,please show me.Thanks! | | the server today is really really slow x-( | Dinh Quang Hiep (mg9h@yahoo.com) | | 7 июл 2001 15:47 | 1 | | | Help!What's wrong with my problem? | Lin | 1027. Снова D++ | 6 июл 2001 20:55 | 2 | Var Text : Array[1..10001] of Char; Long : Integer; D1,D2 : Integer; Now : Integer; Procedure Init; Var S : String; i : Integer; Begin Long := 0; Repeat Readln(S); For i := 1 to Length(S) do If S[i]<>#0 then Text[Long+i] := S[i]; Inc(Long,Length(S)); Until S=''; End; Procedure Main; Var i,j : Integer; P : Integer; Begin P := 0; Now := 0; Repeat Inc(P); If Text[P]+Text[P+1]='(*' then Begin Inc(D1); Now := 2; Inc(P); Continue; End; If Now=2 then If Text[P]+Text[P+1]='*)' then Begin Dec(D1); If D1=0 then Begin If D2<>0 then Now := 1 else Now := 0; End; Inc(P); Continue; End; If Now<2 then Begin If Text[P]='(' then Begin Inc(D2); Now := 1; Continue; End; If Text[P]=')' then Begin Dec(D2); If D2=0 then Now := 0; Continue; End; End; If Now=1 then If Not(Text[P] in ['(',')','0'..'9','+','- ','*','/','=']) then Begin Writeln('No'); Halt; End; If Now=0 then If Text[P]=')' then Begin Writeln('No'); Exit; End; Until P=Long; If (D1<>0) or (D2<>0) then Begin Writeln('No'); Exit; End; Writeln('Yes'); End; Begin Init; Main; End. The first false of your program is : if the text is correct D++ then you should write "YES", not "Yes" or "NO", not "No" ! Hope you will get acc ! 71222119 mailto : trungduck@yahoo.com > Var Text : Array[1..10001] of Char; > Long : Integer; > D1,D2 : Integer; > Now : Integer; > > Procedure Init; > Var S : String; > i : Integer; > Begin > Long := 0; > Repeat > Readln(S); > For i := 1 to Length(S) do > If S[i]<>#0 then > Text[Long+i] := S[i]; > Inc(Long,Length(S)); > Until S=''; > End; > > Procedure Main; > Var i,j : Integer; > P : Integer; > Begin > P := 0; > Now := 0; > Repeat > Inc(P); > If Text[P]+Text[P+1]='(*' then > Begin > Inc(D1); > Now := 2; > Inc(P); > Continue; > End; > If Now=2 then > If Text[P]+Text[P+1]='*)' then > Begin > Dec(D1); > If D1=0 then > Begin > If D2<>0 then Now := 1 > else Now := 0; > End; > Inc(P); > Continue; > End; > If Now<2 then > Begin > If Text[P]='(' then > Begin > Inc(D2); > Now := 1; > Continue; > End; > If Text[P]=')' then > Begin > Dec(D2); > If D2=0 then Now := 0; > Continue; > End; > End; > If Now=1 then > If Not(Text[P] in ['(',')','0'..'9','+','- > ','*','/','=']) then > Begin > Writeln('No'); > Halt; > End; > If Now=0 then > If Text[P]=')' then > Begin > Writeln('No'); > Exit; > End; > Until P=Long; > If (D1<>0) or (D2<>0) then > Begin > Writeln('No'); > Exit; > End; > Writeln('Yes'); > End; > > Begin > Init; > Main; > End. | | Lin | 1027. Снова D++ | 6 июл 2001 20:24 | 1 | {Help!What's wrong with my problem?} Var Text : Array[1..10001] of Char; Long : Integer; D1,D2 : Integer; Now : Integer; Procedure Init; Var S : String; i : Integer; Begin Long := 0; Repeat Readln(S); For i := 1 to Length(S) do If S[i]<>#0 then Text[Long+i] := S[i]; Inc(Long,Length(S)); Until S=''; End; Procedure Main; Var i,j : Integer; P : Integer; Begin P := 0; Now := 0; Repeat Inc(P); If Text[P]+Text[P+1]='(*' then Begin Inc(D1); Now := 2; Inc(P); Continue; End; If Now=2 then If Text[P]+Text[P+1]='*)' then Begin Dec(D1); If D1=0 then Begin If D2<>0 then Now := 1 else Now := 0; End; Inc(P); Continue; End; If Now<2 then Begin If Text[P]='(' then Begin Inc(D2); Now := 1; Continue; End; If Text[P]=')' then Begin Dec(D2); If D2=0 then Now := 0; Continue; End; End; If Now=1 then If Not(Text[P] in ['(',')','0'..'9','+','- ','*','/','=']) then Begin Writeln('No'); Halt; End; If Now=0 then If Text[P]=')' then Begin Writeln('No'); Exit; End; Until P=Long; If (D1<>0) or (D2<>0) then Begin Writeln('No'); Exit; End; Writeln('Yes'); End; Begin Init; Main; End. | | Who has solved the STaircase and why I always get CRASH? | Vladimir Milenov Vasilev | 1017. Лестницы | 6 июл 2001 10:50 | 1 | Here is my program It always gets CRASH? Could you tell me why, please? program staircase; const max=500; var n,i,j:longint; a:array[0..max,0..max]of real; procedure br(n:integer); var i,j:integer; begin for i:=1 to n do for j:=1 to n do if j=1 then a[i,j]:=0 else if (j*(j+1)div 2)<i then a[i,j]:=0 else if j=i then a[i,j]:=1+a[j,j-1] else if (j=i-1)then a[i,j]:=1+a[i,j-1] else if j>i then a[i,j]:=a[i,i] else a[i,j]:=a[i-j,j-1]+a[i,j-1]; end; begin readln(n); br(n); writeln(round(a[n,n]-1)); end. Thank you! | | WA | Le Phuoc Hai Son | 1018. Двоичная яблоня | 6 июл 2001 10:27 | 4 | WA Le Phuoc Hai Son 20 июн 2001 19:36 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'll answer you about your source later, just be a little patient ;) QH@ 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. > 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. | | IOI 2001 - Vietnam National Team | tjiputra | | 6 июл 2001 02:49 | 4 | 1) Tran Quang Khai 2) Tran Thanh Hoai 3) Nguyen Phuong Ngoc 4) Hoang Duc Viet Dung > > 1) Tran Quang Khai > 2) Tran Thanh Hoai > 3) Nguyen Phuong Ngoc > 4) Hoang Duc Viet Dung > > > > > Their English are not very well . How about Bulgary ? > > > > 1) Tran Quang Khai > > 2) Tran Thanh Hoai > > 3) Nguyen Phuong Ngoc > > 4) Hoang Duc Viet Dung > > > > > > > > > > our team is: 1. Jivko Ganev 2. Velin Tzanov 3. Petko Minkov (me, yeah) 4. Nikolay Nikolov | | ************* Help me !! 'Get right route' | Dinh Hong Minh #2 | 1096. Таблички с номерами маршрутов | 5 июл 2001 19:44 | 3 | - Why the last line in output has 3 number? - What range of route ? 1..1000 ? Thanks :) Dinh Quang Hiep (mg9h@yahoo.com) 12 июн 2001 20:16 > - Why the last line in output has 3 number? Because 1 + 2 = 3 :) > - What range of route ? 1..1000 ? U can use integer type for them, btw, the range of numbers of route is 1000 > Thanks Re: :) Grigory Makeev 5 июл 2001 19:44 > U can use integer type for them, btw, the range of >numbers of route is 1000 No, it's not! Starting thinking of this problem i mentioned, that there's nothing said about the numbers of the routes. Are they Integer, Word or Longint? I do think, that's a mistake of the creators. Alright, you say i can use integer to store them. But as i can see, some of them are greater, than 1000! Perhaps, it doesn't matter for you, but it does matter for me, because i just solved if using a primitive Deikstra algorithm for shortest paths. And i do need to know the range of route numbers. | | There are 9 Vietnamese flags and 9 Chinese flags in TOP25. Why ? | Tran Nam Trung (trungduck@yahoo.com) | | 5 июл 2001 13:12 | 5 | 71222119 mailto : trungduck@yahoo.com > mailto : dinhhongminh@yahoo.com > 71222119 = Peter Crakov > mailto : trungduck@yahoo.com Ten xau qua trung oi. Mikhail , Nedved , .. dep hon nhieu. > > 71222119 = Peter Crakov > > mailto : trungduck@yahoo.com > Ten xau qua trung oi. Mikhail , Nedved , .. dep hon nhieu. > > > 71222119 = Peter Crakov > > > mailto : trungduck@yahoo.com > > Ten xau qua trung oi. Mikhail , Nedved , Berger .. dep hon nhieu. | | chep , chu Kim Dung leo nhanh the ?? | Bin | | 3 июл 2001 23:08 | 3 | Tuan roi khong vao chu da lam toi 101 bai roi :( . Hehe anh thay moi co 103 ma ? Chep cac chu hop tac a ? > Kimdung@ | | Is SaratovSU #3 a team ? | Tran Nam Trung (trungduck@yahoo.com) | | 3 июл 2001 20:16 | 4 | Who are the members of it ? 71222119 mailto : trungduck@yahoo.com Yes, it consists of 1) Ilya V. Elterman - the capitan; 2) Andrew V. Lazarev 3) Michael Mirzayanov We are from Russia, Saratov State University (but from different departments). ...and what is DSAP? DSAP is a group of pupils. It consists about 50 members. But in acm.timus.ru they are : 1> Nguyen Trong Hiep 2> Dinh Quang Hiep 3> Tran Nam Trung 4> Dinh Hong Minh 5> Nguyen Van Hieu 6> Pham Hung Son 7> Le Minh Hoang ... You can visit our site at : http://come.to/dsap71222119 mailto : trungduck@yahoo.com > Yes, it consists of > 1) Ilya V. Elterman - the capitan; > 2) Andrew V. Lazarev > 3) Michael Mirzayanov > > We are from Russia, Saratov State University (but from > different departments). > > ...and what is DSAP? > > All of person in DSAP Club ( In acm.timus.ru ) are in National University in HaNoi. We study in Mathematics And Infomatics Department. | | Khong the subit duoc.Tuc qua. | Vua moi chay xuong nha xem phim duoc 1 ty, len chung no da lam x | | 3 июл 2001 00:44 | 1 | | | I'm not Vietnamese. | Dinh Hong Minh | | 2 июл 2001 23:00 | 1 | Внимание решающим! В задаче неправильный пример входных данных! Не смотрите на него, читайте спецификацию. В начале идет количество, потом элементы. Из-за этого глюка я посылал эту задачу 6 раз. | | This problem have any traps ? | Pham Hung Son | 1096. Таблички с номерами маршрутов | 2 июл 2001 16:47 | 2 | I sovle this problem by BFS I think that right but I can't accept it . It have anny traps ? Thanks Yes, this prob use BFS. I think the condition to exchange plate and the condition to end exchange of yours is not right. Just read problem many times and you will get acc. 71222117 mailto : trungduck@yahoo.com > I sovle this problem by BFS > I think that right but I can't accept it . > It have anny traps ? > Thanks | | 1100-Final Standings, HELP! | Bill Liang Huang | | 2 июл 2001 09:36 | 2 | I wrote a program in radix sort, it's simple, i think. But always wa, could anybody give me some tips? or some tricky cases? mail me at blhuang@online.sh.cn, ok? Thank u. You can use the simple algorithm to solve this problem. It'll get Accepted. > I wrote a program in radix sort, it's simple, i think. > But always wa, could anybody give me some tips? > or some tricky cases? > > mail me at blhuang@online.sh.cn, ok? > Thank u. | | Prob 1057 : Good Prob !!! | Tran Nam Trung (trungduck@yahoo.com) | | 2 июл 2001 06:46 | 1 | Because there are two ways to get accepted : The one is brute force, and another is simply. The first one take us more than 10s but the second just take less than 0.05s. Yes, good Prob ! 71222119 mailto : trungduck@yahoo.com | | Read this DH Minh ! | Tran Nam Trung (trungduck@yahoo.com) | | 1 июл 2001 20:03 | 2 | Ong su dung ID cua tui a ? Neu dung thi phai dung bai acc chu sao lai dung bai WA (1050) ? Read this TNT ! Vua moi chay xuong nha xem phim duoc 1 ty, len chung no da lam x 1 июл 2001 20:03 Sorry. You will acc 1050. | | Read this DH Minh ! | Tran Nam Trung (trungduck@yahoo.com) | | 1 июл 2001 19:19 | 1 | Ong su dung ID cua tui a ? Neu dung thi phai dung bai acc chu sao lai dung bai WA (1050) ? |
|
|