Common BoardShow all threads Hide all threads Show all messages Hide all messages | My O(W*H) solution works too slow :( [-] | Chmel_Tolstiy | 1315. MDPAR and MIIAR | 22 Jun 2007 15:49 | 1 | | Here is my code.Who can tell me my mistake???I got WA on test #1 | Anastas | 1446. Sorting Hat | 22 Jun 2007 15:09 | 2 | #include<iostream.h> #include<stdio.h> #include<string.h> struct Magicman{ char name[201]; }; int main() { int i,l,n; char fac[40]; int Slyth[1000]={0},Huffl[1000]={0},Gryff[1000]={0},Raven[1000]={0}; cin>>n; Magicman *a; a=new Magicman[n+1]; for(i=1;i<=n;i++){ gets(a[i].name); cin>>fac; if(strcmp(fac,"Slytherin")==0) Slyth[++Slyth[0]]=i; if(strcmp(fac,"Hufflepuff")==0) Huffl[++Huffl[0]]=i; if(strcmp(fac,"Gryffindor")==0) Gryff[++Gryff[0]]=i; if(strcmp(fac,"Ravenclaw")==0) Raven[++Raven[0]]=i; } cout<<"Slytherin:"<<endl; for(i=1;i<=Slyth[0];i++){ l=strlen(a[Slyth[i]].name); a[Slyth[i]].name[l]=NULL; cout<<a[Slyth[i]].name<<endl; } cout<<endl<<"Hufflepuff:"<<endl; for(i=1;i<=Huffl[0];i++){ l=strlen(a[Huffl[i]].name); a[Huffl[i]].name[l]=NULL; cout<<a[Huffl[i]].name<<endl; } cout<<endl<<"Gryffindor:"<<endl; for(i=1;i<=Gryff[0];i++){ l=strlen(a[Gryff[i]].name); a[Gryff[i]].name[l]=NULL; cout<<a[Gryff[i]].name<<endl; } cout<<endl<<"Ravenclaw:"<<endl; for(i=1;i<=Raven[0];i++){ l=strlen(a[Raven[i]].name); a[Raven[i]].name[l]=NULL; cout<<a[Raven[i]].name<<endl; } return 0; } | WA#13 | Алексей | 1348. Goat in the Garden 2 | 19 Jun 2007 21:57 | 3 | WA#13 Алексей 13 Apr 2005 01:31 Why I have Crash (FLT_INVALID_OPERATION)? The site can be a point Look that there was no division into zero. I don't have division by zero and I've considered that point A can be equal to B, B to C,A to C, but I've still got WA#13. Maybe, some another hint? Edited by author 19.06.2007 21:57 | a silly problem | FireHeart | 1220. Stacks | 19 Jun 2007 17:33 | 5 | I define : type PNODE=^NODE NODE=record value:longword; pre:PNODE; end Var A:array[1..1000] of PNODE; then memory used is 1064KB but when add : type PNODE=^NODE NODE=record value:longword; pre:PNODE; end Var A:array[1..1000] of PNODE; last:array[1..1000] of PNODE; then memory used is 932KB ---> what happend ?? Depend on the way you use the array. The memory is not only the memory you declare in your program but also the memory to run your program. Memory = memory you declare + memory to run your program . In Vietnamese : Làm sao tính được vậy anh, em đã loại hết tất cả những gì có thể bỏ được rồi. Vẫn bị MLE it is not a necessary to allocate memory for all memory that you declare(but for memory that you use it is necessary) memory can allocates by blocks, and only if you use it algorithm that rule this process can depends on total memory that you declare and it is possible that in this situation compiler uses such algorithm In Vietnamese : Vì 1 con trỏ của em tốn tới 8 byte ( 4 byte cho longword và 4 byte cho việc "trỏ" ) -> N <= 100000 thì em đã mất tới 800000 byte > 0.75 MB rồi . MLE là điều tất yếu . Anh dùng mảng , kô dùng con trỏ cũng mất tới 700 KB :) . Edited by author 19.06.2007 17:34 | Test number #26 | Rafal | 1427. SMS | 19 Jun 2007 14:19 | 2 | Do you know what's so special about it? I have WA :( I had this problem. Change result from Word to LongWord. Result may be up to 100000 | Please HELP!!! | Serg | 1005. Stone Pile | 19 Jun 2007 11:36 | 4 | Please HELP!!! Why WA on test 1??? program Project_kamni; {$APPtype CONSOLE} uses SysUtils; var s1,s2:string; m:array[1..101]of int64; a,b,t,n,j,k,r:int64; i:longint; begin readln(n); s1:=''; s2:=''; for i:=1 to n do begin readln(m[i]); s1:=s1+'0'; s2:=s2+'1' end; t:=992147483645; while s1<>s2 do begin i:=length(s1); while (s1[i]='1') do begin s1[i]:='0'; dec(i); end; s1[i]:='1'; a:=0; b:=0; for i:=1 to n do begin if s1[i]='1' then a:=a+m[i] else b:=b+m[i]; end; r:=abs(a-b); if r<t then t:=r; end; writeln(t); end. Please write the test which there did not pass your program. Please help!!!!!!!!!!!! I dont know, why I have WA1 test: 3 2 4 5 you must use read instead of readln | problem 1032 | Razvan Brezulianu | | 18 Jun 2007 16:15 | 1 | To admins you say in the problem that we should output what set of numbers that accomplish the requirement of the problem but I get WA#1 | And now let's talk | Dominator | | 18 Jun 2007 09:18 | 6 | For more information olim_s@bk.ru Dominator think when he cool guy. [censored] Edited by moderator 18.06.2007 09:20 | How to solve this problem ?? | ProgBeat | 1533. Fat Hobbits | 18 Jun 2007 01:37 | 1 | I got AC with very optimized backtraking, I think the problem has simple solution.. Could you tell me your algo or send me your code in case if you solved it without backtraking ? e-mail: www-www-www@mail.ru | Advice | Olzhas2dy | 1050. Preparing an Article | 17 Jun 2007 03:49 | 1 | Advice Olzhas2dy 17 Jun 2007 03:49 If you want ACC fast, don't use "super-extra-hiper-shmiper smart" solution. Very silly and small one works well(not very fast though). | 1 <= a, n <= 32767 is it true for all tests?? | wxsxg | 1132. Square Root | 16 Jun 2007 16:59 | 2 | I got integer division by zero I want to know whether n==0 appears in the test? You had WA1 on this problem earlier. In what there was a mistake? Can at me same.... And please post some tests for this problem | Please HELP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | BAron | 1132. Square Root | 16 Jun 2007 16:56 | 1 | Give me a few tests, please! Anybody, who had WA1 and then had AC, please help me!!!!!!!! Tests or any hints, please!!!!!!! Edited by author 29.06.2007 09:00 | Strange.. OLE at #15... | Agnimon | 1029. Ministry | 15 Jun 2007 21:36 | 2 | So anyone has the same problem as mine..? program dafen; const maxm=100; maxn=500; var i,m,n,j,mini:integer; min:longint; f,w:array[1..maxm,1..maxn] of longint; g:array[1..maxm,1..maxn] of 0..3; {1:from downstair; 2:from the left; 3:from the right} begin readln(m,n); for i:=m downto 1 do for j:=1 to n do read(w[i,j]); fillchar(f,sizeof(f),127); for i:=1 to n do f[1,i]:=w[1,i]; for i:=2 to m do begin {left to right} f[i,1]:=f[i-1,1]+w[i,1]; g[i,1]:=1; for j:=2 to n do begin if f[i,j]>f[i-1,j]+w[i,j] then begin f[i,j]:=f[i-1,j]+w[i,j]; g[i,j]:=1; end; if f[i,j]>f[i,j-1]+w[i,j] then begin f[i,j]:=f[i,j-1]+w[i,j]; g[i,j]:=2; end; end; {right to left} if f[i,n]>f[i-1,n]+w[i,n] then begin f[i,n]:=f[i-1,n]+w[i,n]; g[i,n]:=1; end; for j:=n-1 downto 1 do begin if f[i,j]>f[i,j+1]+w[i,j] then begin f[i,j]:=f[i,j+1]+w[i,j]; g[i,j]:=3; end; end; end; min:=maxlongint; for i:=1 to n do begin if f[m,i]<min then begin min:=f[m,i]; mini:=i; end; end; i:=m; j:=mini; while not(i=1) do begin writeln(j); case g[i,j] of 1:dec(i); 2:dec(j); 3:inc(j); end; end; writeln(j); end. Err, the problem solved by increasing array bounds to 200*600, and change longint to double= =... evil datas.. | Changes in problem 1390 "Shots at walls" (+) | Sandro (USU) | 1390. Shots at Walls | 15 Jun 2007 14:52 | 1 | New tests were added. The number of lines doesn't exceed 50000 now (100000 in the old version). Some authors lost AC. | Very nice problem. (-) | Ilya Rasenstein (Lyceum #40) | 1492. Vasya's Dad 2 | 14 Jun 2007 23:22 | 4 | My respect to the author. It was interesting to solve it. Thanks :) Great thanks to the author! The problem is really nice) | Very nice problem ;) | Burunduk1 | 1365. Testing Calculator | 14 Jun 2007 21:30 | 2 | I agree with you. I accept it with first attempt. | Give me some tests!PLZ! I have WA test1!!! | Krukov=>[ProgMyaZzz] | 1141. RSA Attack | 14 Jun 2007 19:01 | 1 | {$N+,E-} program tmp2; {$APPTYPE CONSOLE} uses SysUtils; var i,k,j,p,q,d:integer; n,e,c:int64; function pow1(a,k:int64):int64; var b:int64; begin b:=1; while k>0 do if k mod 2 = 0 then begin k:=k div 2; a:=a*a; end else begin dec(k); b:=b*a; end; pow1:=b; end; function powmod(a,k,n:int64):int64; var b:int64; begin b:=1; while k>0 do if k mod 2 = 0 then begin k:=k div 2; a:=(a*a) mod n; end else begin dec(k); b:=(b*a) mod n; end; powmod:=b; end; procedure factor(n:integer); var d:integer; begin for d:=2 to trunc(sqrt(n)) do if n mod d =0 then begin p:=d; q:=n div d; exit; end; end; begin { TODO -oUser -cConsole Main : Insert code here } { reset(input,'data.in'); rewrite(output,'data.out');} readln(k); for i:=1 to k do begin readln(e,n,c); factor(n); d:=1; while (1+k*(p-1)*(q-1)) mod e <> 0 do inc(k); d:=(1+k*(p-1)*(q-1)) div e; writeln(powmod(c,d,n)); end; end. | Could you give me some tests?I WA on test 8 | tantian | 1486. Equal Squares | 14 Jun 2007 11:30 | 1 | Could you give me some tests?I WA on test 8 | a little problem | puella | 1009. K-based Numbers | 13 Jun 2007 19:59 | 2 | Edited by author 21.05.2008 14:39 Edited by author 21.05.2008 14:39 | What is wrong with my code? | Alexander Bovkun | 1028. Stars | 13 Jun 2007 17:36 | 3 | I used RSQ(Range Sum Query) to solve this problem, but got Wrong Answer. Everything seems to be OK and I don't know where is a mistake. Here is my code: {$A+,B-,D+,E+,F-,G-,I+,L+,N-,O-,P-,Q-,R+,S+,T-,V+,X+} {$M 16384,0,655360} Program Stars; Var N:Integer; RSQ:Array[1..32000] Of Integer; Levels:Array[0..14999] Of Integer; I,J,K,X,Y:LongInt; Begin ReadLn(N); For I:=1 To N Do Begin ReadLn(X,Y); J:=X;K:=0; While J>=1 Do Begin K:=K+RSQ[J]; J:=J-(J And ((J-1) Xor J)); End; Inc(Levels[K]); While X<=32000 Do Begin Inc(RSQ[X]); X:=X+(X And ((X-1) Xor X)); End; End; For I:=0 To N-1 Do WriteLn(Levels[I]); End. If you put the line "Inc(X);" after "ReadLn(X,Y)" and change all 32000 on 32001 it will be AC. Complexity of my algorithm is N*Log(M) where N is number of stars and M is maximal possible value of axis of the star. It works only 0.031 sec! Edited by author 13.03.2005 15:07 Where can I found out more about RSQ? |
|
|