| Show all threads Hide all threads Show all messages Hide all messages |
| How can i do faster? | Yashar Abbasov | 1189. Pairs of Integers | 22 Nov 2007 14:37 | 1 |
|
| C/C++ Compiler switches changed (+) | Vladimir Yakovlev (USU) | | 21 Nov 2007 23:35 | 1 |
Switch /O1 was added to command line of C/C++ compiler. This switch is used instead of default /O2 switch. Description from compiler help: /O1 optimize for maximum speed, but disable some optimizations which increase code size for a small speed benefit /O2 optimize for maximum speed (DEFAULT) ICL compiler sometimes makes wrong code with /O2 switch. To prevent wrong verdicts we have changed switches but loose some performance. Some programs will work a little bit slower now. Current compiler's command line: // C icl /GX /TC /Za /O1 /D ONLINE_JUDGE // C++ icl /GX /TP /Za /O1 /D ONLINE_JUDGE (See http://acm.timus.ru/help.aspx?topic=cpp ) Edited by author 21.11.2007 23:39 |
| WA14??? | Tural Neymanov | 1295. Crazy Notions | 21 Nov 2007 11:18 | 1 |
WA14??? Tural Neymanov 21 Nov 2007 11:18 can someone give me tests to compile my programm? |
| what the answer | ToN AC119 | 1244. Gentlemen | 21 Nov 2007 10:07 | 4 |
-1 Edited by author 03.01.2008 14:22 |
| Why Wrong answer(Pascal) | Sasha | 1001. Reverse Root | 21 Nov 2007 00:22 | 2 |
program BackSQRT; {$APPTYPE CONSOLE} uses SysUtils; var f,fout: Text; a:array[0..99999999] of extended; tmp: int64; count,j: 0..99999999; begin Count:=0; assignfile(f,'input.txt'); reset(f); while not Eof(f) do begin while not Eoln(f) do begin read(f,tmp); if tmp<0 then continue; a[count]:=tmp; inc(count); // -1 end; readln(f); end; closefile(f); assignfile(fout,'out.txt'); rewrite(fout); for j:=count-1 downto 0 do writeln(fout,sqrt(a[j]):0:4); closefile(fout); end. use standart input and output stream... |
| Why my program work so slow? | Romko [Lviv NU] | 1249. Ancient Necropolis | 20 Nov 2007 20:24 | 4 |
I've only read and check, and don't read whole input. Why it work's less then 4 sek? [code deleted] Edited by author 26.01.2007 17:17 Use scanf instead of cin Input file is very big >10MB but better use Pascal:) I don't optimize input at all. It works about 1.3 sec After simple optimization 0.328 sec Edited by author 26.01.2007 16:15 Thank you! I've changed cin to scanf and got AC in 1.5 sec )) Try to use "gets()" instead "scanf()" and "cin". You can solve it with 2 strings (length = 2*m + 2). I've get AC at 0.156 sec. And some solution are faster. |
| WA 4 | Backs [Rogatnev Sergey] | 1571. Interpreters | 20 Nov 2007 19:38 | 2 |
WA 4 Backs [Rogatnev Sergey] 1 Nov 2007 14:51 why WA on test 4? what answer on test: input.txt 2 a b ??? |
| Who can help me with the 4th test? | terro | 1189. Pairs of Integers | 20 Nov 2007 17:44 | 1 |
Wrong Answer with test 4. I don't know what happened. So who can help me with it? |
| I get WA on test 7. Could someone give me any hint? | tantian | 1041. Nikifor | 20 Nov 2007 16:33 | 2 |
program ex; const maxn=2000; maxm=50; zero=1e-15; var g: Array[0..maxn, 1..maxm] of extended; cost: Array[1..maxn] of longint; from: Array[1..maxn] of longint; n, m: longint; ans: longint; num: Array[1..maxm] of longint; tot: longint; kk: Array[1..maxn] of longint; procedure init; var i, j: longint; begin read(n, m); for i:=1 to n do for j:=1 to m do read(g[i, j]); for i:=1 to n do begin read(cost[i]); from[i]:=i; end; end; procedure qsort(l, r: longint); var i, j: longint; x, y: longint; t: longint; begin i:=l; j:=r; x:=cost[(l+r) shr 1]; y:=from[(l+r) shr 1]; while i<=j do begin while (cost[i]<x)or(cost[i]=x)and(from[i]<y) do inc(i); while (cost[j]>x)or(cost[j]=x)and(from[j]>y) do dec(j); if i<=j then begin g[0]:=g[i]; g[i]:=g[j]; g[j]:=g[0]; t:=cost[i]; cost[i]:=cost[j]; cost[j]:=t; t:=from[i]; from[i]:=from[j]; from[j]:=t; inc(i); dec(j); end; end; if j>l then qsort(l, j); if i<r then qsort(i, t); end; function can(x: longint): boolean; var i, j: longint; len1, len2: extended; sum: extended; co: extended; tt: extended; temp: Array[1..maxn] of extended; begin for i:=1 to tot do begin sum:=0; len1:=0; len2:=0; for j:=1 to m do begin sum:=sum+g[x, j]*g[i, j]; len1:=len1+g[x, j]*g[x, j]; len2:=len2+g[kk[i], j]*g[kk[i], j]; end; len1:=sqrt(len1); len2:=sqrt(len2); if abs(len1)<=zero then exit(false); co:=sum/len1/len2; tt:=len1*co; for j:=1 to m do temp[j]:=g[kk[i], j]*tt/len2; for j:=1 to m do g[x, j]:=g[x, j]-temp[j]; end; for j:=1 to m do if abs(g[x, j])>zero then exit(true); exit(false); end; procedure solve; var i: longint; begin qsort(1, n); tot:=1; num[1]:=from[1]; ans:=ans+cost[1]; kk[1]:=1; for i:=2 to n do if can(i) then begin inc(tot); kk[tot]:=i; num[tot]:=from[i]; ans:=ans+cost[i]; if tot=m then exit; end; end; procedure print; var i, j: longint; t: longint; begin if tot<m then writeln(0) else begin writeln(ans); for i:=1 to m do for j:=i+1 to m do if num[i]>num[j] then begin t:=num[i]; num[i]:=num[j]; num[j]:=t; end; for i:=1 to m do writeln(num[i]); end; end; begin init; solve; print; end. |
| Please,Help Me!!!! I have WA#1 on C++!Thank you Very much!!!!!! I Really need your help!!!Here is my code: | CHIDEMYAN SERGEY | 1446. Sorting Hat | 20 Nov 2007 01:22 | 3 |
OH,I find my mistake!!! Edited by author 05.05.2007 16:28 can you tell me what the mistake is. coz im also getting WA in test#1 itself Solved. Well, i'd given an endl before even printing the results.:( |
| Please HELP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | Furious Wolf | 1132. Square Root | 20 Nov 2007 01:21 | 3 |
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 24.06.2007 19:23 |
| AC 0.001s 120 k | Bourne | 1297. Palindrome | 19 Nov 2007 15:47 | 2 |
program Bourne; var x:char; a:array[1..1000] of char; n,i,start,len,maxlen:integer; procedure find(p,q:integer); var p0,q0:integer; begin p0:=p; q0:=q; while (p0>=1)and(q0<=n)and(a[p0]=a[q0]) do begin inc(len,2); inc(q0); dec(p0); end; if len>maxlen then begin maxlen:=len; start:=p0; end; end; begin n:=0; repeat read(x); inc(n); a[n]:=x; until eoln; maxlen:=0; for i:=1 to n do begin len:=0; find(i,i+1); len:=1; find(i-1,i+1); end; for i:=1 to maxlen do write(a[start+i]); writeln; end. I used DP O(n^2) var st : ansistring; f : array [0..1010,0..1010] of boolean; i,j,cx,cy,max : longint; begin readln(st); max:=0; for i:=1 to length(st) do for j:=1 to i do f[i,j]:=true; for i:=1 to length(st)-1 do for j:=1 to length(st)-i do if st[j] = st[i+j] then f[j,i+j]:=f[j+1,i+j-1] else f[j,i+j]:=false; max:=-1; for i:=1 to length(st) do for j:=0 to length(st)-i do if (f[i,i+j]) and (j>max) then begin cx:=i; cy:=i+j; max:=j; end; for i:=cx to cy do write(st[i]); writeln; end. |
| Any Hint? | Jordan | 1180. Stone Game | 18 Nov 2007 22:49 | 4 |
|
| Binary Search AC program | Bogdan A. Stoica [fireatmyself] | 1066. Garland | 18 Nov 2007 21:33 | 2 |
#include <stdio.h> #define eps 0.00000001 double A, B=((1<<31)-1), DMin=((1<<31)-1); int N; void bs() { double p1 = A, p2 = 0, mij, a1, a2, a3, min; int i; while ((p1-p2)>eps) { min = A; mij = (p1+p2)/2; a1 = A; a2 = mij; for (i = 2; i < N; i++) { a3 = 2*(a2+1)-a1; a1 = a2; a2 = a3; if (a3 < 0) { p2 = mij+eps; break; } else if (min > a3) min = a3; } if (i == N) { if ((B-a3)<eps) p2=2*p1; if ((DMin-min) > eps) DMin = min, B = a3; p1 = mij-eps; } } } int main() { scanf("%d %lf", &N, &A); bs(); printf("%.2lf\n", B); return 0;
} Can you just explain in simple terms the method you've used. Edited by author 01.12.2007 02:29 |
| WA, TL, Crash.... Test 1. | ilyamit | 1102. Strange Dialog | 18 Nov 2007 21:06 | 2 |
Why this "solve" got WA1??? #include <iostream> using namespace std; int main() { cout << "YES\nNO\nYES\nNO\nNO\nNO"; return 0; } :-) Example test is not test #1. |
| who can show me the optimal memory strategy? | AlainDelon | 1015. Test the Difference! | 18 Nov 2007 20:41 | 1 |
I got AC but used lots of memory. currently I use a very large lookup table such as int hash[7][7][7][7][7][7] for look up a given dice's scheme what's the optimal approach that can minimize the memory usage and also get 0.001s time result? Thanks! |
| Three hords intersecting at the same point | Pavel Semushin [Samara SAU] | 1591. Abstract Thinking | 18 Nov 2007 18:38 | 1 |
Am i right that it's not important that some three hords intersect at the same point, and this figure is according to condition of promlem? For example, three diagonals of ideal 6-polygon which intersects at its center make an interesting triangle, aren't they? |
| Why I have the wrong answer? (Pascal) | BitLord | 1001. Reverse Root | 18 Nov 2007 18:25 | 2 |
Please tell me, why do i have the wrong answer in next code? program Project2; var fi:text; fo:text; i,j:integer; a:array[1..1000000] of int64; begin i:=0; while not EOF do begin inc(i); read(a[i]); end; for j:=i downto 1 do writeln(sqrt(StrToFloat(IntToStr(a[j]))):0:4); end. use seekeof for numbers StrToFloat(IntToStr(a[j])) is not needed use extended |
| Why on this code stands out "Compilation error"? | Anix | 1591. Abstract Thinking | 18 Nov 2007 13:26 | 2 |
Thank's. VS6.0 has very stupid compiler :) Edited by author 18.11.2007 21:28 when you submit your code you can use option "reply to this email" maybe you use Visual Studio 6.0 and it's stupid compiler for (int i=0;i<k;i++) // there you define i { tmp*=n; n--; } // end of area where i is visible for (i=1;i<=k;i++) ^^^^^^^^^^ i is undefined there { d*=i; } in c++ standart you can do such cicles for (int i = 0; i < 4; i++) ..... for (int i = 0; i < 4; i++) ..... but stupid VS 6.0 compiler think that it is wrong anyway you can do as this: int i; for (i = 0; i < 4; i++) ... for (i = 0; i < 4; i++) ... Edited by author 18.11.2007 13:27 |
| No subject | ilyamit | 1102. Strange Dialog | 17 Nov 2007 18:44 | 1 |
|