| Show all threads Hide all threads Show all messages Hide all messages |
| And what about solving this problem without any arrays? | Oleg Strekalovsky [Vologda SPU] | 1048. Superlong Sums | 30 Mar 2009 00:06 | 6 |
I solved this problem on Java. Memory < 1 М .Time was about 0.8 c. Without any arays!!! Are your can? =). Thanks to Fyodor Menshikov. He was rigth about limitation. Using recursive procedure like topological sorting. Recursion implicitly uses array (stack), so used memory will be the same. Edited by author 13.01.2009 23:26 And how? Think. Look at memory compsumption of first solutions of the problem. if(A+B > 9) ..... Console.Write(last+1); if(A+B == 9) count++; ...... if(A+B < 9) Console.Write(last); but it's slow,so it's not a good way |
| The answer for n=3000? | AmBush | 1222. Chernobyl’ Eagles | 29 Mar 2009 19:32 | 8 |
What is the answer for n=3000? According to my problem it is: 1112410638837951982681559213420228436655660132143101893639583499479104 8307860224498112075664780555124758923322998295448875554498944133575085 7206969739792707314008867553774340959765426840307082886757146900689409 1769558402678831747586833656908719011631685677289799215417532225045801 3194444896132535792828846054226294650004927200184834052327444607699483 6595280893152817992146653301160115779064762003728308491537220749832979 2557104621996394714041315150395706599135856376433569557036792447902521 76364500701 but i've got WA HELP! n=3000 6230944380615661730540866744905062220607354471963766287778397756065940 6962697903814082629320941801101660304581383981489487361062625347661816 5706321659264965023017203487210780255823880970691747085650866739360077 645709393425508719830393155473510779779930751 But I got wa too. 1322070819480806636890455259752144365965422032752148167664920368226828 5973467048995407783138506080619639097776968725823559509545821006189118 6534272525795367402762022519832080387801477422896484127439040011758861 8041128947815623094438061566173054086674490506178125480344405547054397 0388958174653682549161362208302685637785822902284163983078878969185564 0408489893760937324217184635993869 13220708194808066368904552597521443659654220327521481676649203682268285973467048 99540778313850608061963909777696872582355950954582100618911865342725257953674027 62022519832080387801477422896484127439040011758861804112894781562309443806156617 30540866744905061781254803444055470543970388958174653682549161362208302685637785 82290228416398307887896918556404084898937609373242171846359938695516765018940588 109060426089671438864102814350385648747165832010614366132173102768902855220001 78269792221766377248792586107312578551454955298456387837931004855964813172193821243390064215949238600077681954053753825948909941306968357700343451652009989159020094600778289423859975436358546313727455317042603649908448160723189846384364576128985442328158891806918309846544996297697505373844135967311576127112637752359444869773878802929985672496258464403635036929317966161945895754817512140406205791563756008285751669647079656658308372789688485874728678798223164136163414900736 When n=3000 my AC program print: 1322070819480806636890455259752144365965422032752148167664920368226828597346704899540778313850608061963909777696872582355950954582100618911865342725257953674027620225198320803878014774228964841274390400117588618041128947815623094438061566173054086674490506178125480344405547054397038895817465368254916136220830268563778582290228416398307887896918556404084898937609373242171846359938695516765018940588109060426089671438864102814350385648747165832010614366132173102768902855220001 Because correct is: 1322070819480806636890455259752144365965422032752148167664920368226828597346704899540778313850608061963909777696872582355950954582100618911865342725257953674027620225198320803878014774228964841274390400117588618041128947815623094438061566173054086674490506178125480344405547054397038895817465368254916136220830268563778582290228416398307887896918556404084898937609373242171846359938695516765018940588109060426089671438864102814350385648747165832010614366132173102768902855220001 |
| Format Problem!!! | Sergio Marquez | 1222. Chernobyl’ Eagles | 29 Mar 2009 19:24 | 7 |
How Can I show the longest value with all digits. Now I show for n=3000 1.32207e+477 I use long double. somebody can help me???? Use array friend, write your own multiply function. Timus array max size = 64 K (or i may wrong) which means you can create char array[64000] store up to 64K digit Edited by author 16.04.2007 20:37 Edited by author 16.04.2007 20:56 size of array is not limited. if you need you can create array of any size. you must to implemet your own multiplication. algorithm is the same as you do it in your exercise book if in pascal you can use extended |
| My method | wu hao | 1222. Chernobyl’ Eagles | 29 Mar 2009 19:23 | 2 |
F[i] = Max[F[i-j]*j} (0<i<=20) 1 (i=0) F[i-3]*3 (i>20) In this way,you can solve the problem in O(n^2). Edited by author 28.01.2009 03:58 |
| Need help!!! | Lebedev_Nicolay[Ivanovo SPU] | 1220. Stacks | 29 Mar 2009 15:50 | 2 |
I had MLE #1 with 2 arrays: (C ++) int a[ 100000 ], short b[ 100000 ]; How to use 1 array instead of two??? int a[ 100000 ], short b[ 1000 ]; |
| Very strange tests | Fyodor Menshikov | 1317. Hail | 29 Mar 2009 05:04 | 3 |
I know solution that gets AC with parameter EPS from 1e-0 to 1e-15 (1e+1 and 1e-16 get WA). It is _very_ strange that tests allow such inaccuracy. It depends on the way use solve the problem. If you do all calculations in integers, any EPS from 1e-0 to 1e-15 will give right answer =) If you do all calculations in integers, any EPS from 1e-0 to 1e-15 will give right answer =) How can you do all calculations in integers if there are a lot of real numbers in input and no limits on number of digits after decimal point? |
| MLE #1 | Lebedev_Nicolay[Ivanovo SPU] | 1220. Stacks | 28 Mar 2009 23:31 | 8 |
MLE #1 Lebedev_Nicolay[Ivanovo SPU] 1 Mar 2009 16:10 I use : int a[ 100000 ]; short num[ 100000 ]; And I have MLE #1!!! 100000 * 4 + 100000 * 2 = 600000 bytes + plus memory for your programm. Memory limit can be 750000 bytes instead of 750 Kb. Re: MLE #1 Lebedev_Nicolay[Ivanovo SPU] 1 Mar 2009 21:37 Re: MLE #1 Vedernikoff Sergey (HSE: EconomicsForever!) 1 Mar 2009 21:44 You use too much memory. Try to fit into one array int[100000]... Re: MLE #1 Lebedev_Nicolay[Ivanovo SPU] 1 Mar 2009 23:12 Can you prompt me? I can't think up how to do it. Re: MLE #1 Vedernikoff Sergey (HSE: EconomicsForever!) 2 Mar 2009 03:15 For example, look at corresponding section in D. Knuth's book (something about several stacks in one memory segment) Re: MLE #1 Lebedev_Nicolay[Ivanovo SPU] 4 Mar 2009 23:18 I can't find it!? Can you tell me any idea??? Re: MLE #1 Amirbekov Artem[Ivanovo SPU] 28 Mar 2009 23:31 Just use the "realloc()" function ;-) |
| N Dijkstras rulezz =) | Глащенко Никита | 1004. Sightseeing Trip | 28 Mar 2009 22:39 | 1 |
|
| need some help(WA 1) | Hanzbrow (TNU) KCC | 1191. Catch the thief! | 28 Mar 2009 20:22 | 1 |
just why WA 1? #include<iostream> using namespace std; int main() { int l, n, k; cin>>l>>n; while(n--){ cin>>k; if(l<=k) {cout<<"YES"; return 0;} l-=k; l+=l%k; } cout<<"NO"; return 0; } |
| WA3. What the test it is? | Programmer | 1317. Hail | 28 Mar 2009 13:11 | 1 |
|
| my java answer, had passed, but too slow and waste memory! | gjlsx | 1001. Reverse Root | 28 Mar 2009 12:51 | 2 |
import java.io.BufferedReader; import java.io.FileReader; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.Reader; import java.io.StreamTokenizer; import java.io.Writer; import java.util.Stack; import java.util.LinkedList; public class ACM1001 {
Reader reader = null; Writer writer = null; StreamTokenizer in = null; PrintWriter out = null; boolean oj = System.getProperty("ONLINE_JUDGE") != null; Stack<Double> dInput = null; LinkedList<Double> dOuput = null; BufferedReader bufReader= null;
public void run() { try{ reader = oj ? new InputStreamReader(System.in) : new FileReader("input1001.txt"); bufReader= new BufferedReader(reader); in = new StreamTokenizer(bufReader); writer = new OutputStreamWriter(System.out); out = new PrintWriter(writer);
dInput = new Stack<Double>(); dOuput = new LinkedList<Double>(); int j = in.nextToken(); while(j != StreamTokenizer.TT_EOF) { if(j == StreamTokenizer.TT_NUMBER) { dInput.push(in.nval); } j = in.nextToken(); } solve(); out.flush(); } catch (Exception e) { e.printStackTrace(); } }
public void solve() { //long 类型的最大值的常量,该值为 2^63 -1 至 2^-63 //double:(2-2-52)·2^1023 至 2^-1074 while(!dInput.isEmpty()){ double dva = dInput.pop(); double x=Math.sqrt(dva); dOuput.add(x); } //BigDecimal 未不可变的、任意精度的有符号十进制数 while(!dOuput.isEmpty()){ System.out.printf("%.4f \n",dOuput.removeFirst()); } } /** * @param args */ public static void main(String[] args) { new ACM1001().run(); } } import java.io.BufferedReader; import java.io.FileReader; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.Reader; import java.io.StreamTokenizer; import java.io.Writer; import java.util.Stack; import java.util.LinkedList; public class ACM1001 {
Reader reader = null; Writer writer = null; StreamTokenizer in = null; PrintWriter out = null; boolean oj = System.getProperty("ONLINE_JUDGE") != null; Stack<Double> dInput = null; LinkedList<Double> dOuput = null; BufferedReader bufReader= null;
public void run() { try{ reader = oj ? new InputStreamReader(System.in) : new FileReader("input1001.txt"); bufReader= new BufferedReader(reader); in = new StreamTokenizer(bufReader); writer = new OutputStreamWriter(System.out); out = new PrintWriter(writer);
dInput = new Stack<Double>(); dOuput = new LinkedList<Double>(); int j = in.nextToken(); while(j != StreamTokenizer.TT_EOF) { if(j == StreamTokenizer.TT_NUMBER) { dInput.push(in.nval); } j = in.nextToken(); } solve(); out.flush(); } catch (Exception e) { e.printStackTrace(); } }
public void solve() { //long 类型的最大值的常量,该值为 2^63 -1 至 2^-63 //double:(2-2-52)·2^1023 至 2^-1074 while(!dInput.isEmpty()){ double dva = dInput.pop(); double x=Math.sqrt(dva); dOuput.add(x); } //BigDecimal 未不可变的、任意精度的有符号十进制数 while(!dOuput.isEmpty()){ System.out.printf("%.4f \n",dOuput.removeFirst()); } } /** * @param args */ public static void main(String[] args) { new ACM1001Solve2().run(); } } class ACM1001Solve2 extends ACM1001 { public void run() { try{ reader = oj ? new InputStreamReader(System.in) : new FileReader("input1001.txt"); bufReader= new BufferedReader(reader); in = new StreamTokenizer(bufReader); writer = new OutputStreamWriter(System.out); out = new PrintWriter(writer);
dInput = new Stack<Double>(); int j = in.nextToken(); while(j != StreamTokenizer.TT_EOF) { if(j == StreamTokenizer.TT_NUMBER) { solve2(in.nval); } j = in.nextToken(); } bufReader.close(); bufReader = null; reader.close(); reader = null; while(!dInput.isEmpty()){ System.out.printf("%.4f \n",dInput.pop()); } out.flush(); dInput.clear(); dInput = null; out = null; writer.close(); writer = null; } catch (Exception e) { e.printStackTrace(); } finally{ reader = null; writer = null; } }
private void solve2(double nn) { double x=Math.sqrt(nn); dInput.push(x); } }//end class ACM1001Solve2 |
| Very strange (( WA on the 1st Test | Donat | 1029. Ministry | 28 Mar 2009 01:32 | 4 |
It's not my first task here on Timus. But for this task I had WA #1. I invented a lot of tests and all of them is solved by my DP solution (and sample of course). No chars in answer except '\n'. Anybody can tell me what's can be wrong? Mine solution have WA1 too... It is very strange because test Nr1 must be the test from the sample... don't must. but usualy test "Nr1 be the test from the sample..." Edited by author 25.12.2006 09:25 here test #1 is not the sample test |
| what mean wrong "Wrong answer #1"? | 连连 | 1029. Ministry | 28 Mar 2009 01:14 | 2 |
who can give me some test data? Edited by author 28.03.2009 01:14 Edited by author 28.03.2009 01:14 |
| useful test for wa#12 | Crash_access_violation | 1681. Brother Bear's Garden | 27 Mar 2009 16:41 | 3 |
7 3 6 8 3 8 1 7 0 3 4 0 6 1 9 6 If you draw this polygon on paper, you understand yours mistake ;) Edited by author 06.03.2009 21:05 By the way the correct answer is 0.38528021 I have WA 12 too. I understood why my solution is wrong. So, what the idea of right solution? |
| Does the result validation mechanism runs correctly? | dreamlover | 1002. Phone Numbers | 26 Mar 2009 18:19 | 2 |
Nart27 has post the 10 test cases of this problem. I got wrong answer of test10, following is the comparison between my result and contents of Nart27's "phone9.out": ________________________________phone9.out abbacc eeeddfd rrspps uuuvvtt xwwwwx zqooozq wyywxwy tuvvvu sprrrrp ffefed ababbab 222222 3333333 777777 8888888 999999 0000000 9999999 888888 7777777 333333 2222222 ________________________________my result 222222 3333333 777777 8888888 999999 0000000 9999999 888888 7777777 333333 2222222 ccacbb eeddfed ppsrpr vvvuuuv ywwyxx zzzoqoo xxxwxxw tvuvvt prppspr deedde baccabc ________________________________ Thers are sentences like this in the problem description: "If there are more solutions having the minimum number of words, you can choose any single one of them." can anybody tell me is it really the case? Sorry it's my fault, there is an other problem in my program. I've got ac! |
| Anti WA15 | derxyz | 1648. Yachts | 26 Mar 2009 13:51 | 1 |
this test help me find my bug... in: 4 5 3 1 7 9 out: 20 12 |
| wa37!!!!!!!!!!!!!!!!!!!!!!! | Mikucon | 1130. Nikifor's Walk | 26 Mar 2009 13:32 | 1 |
Program FLY_ural1130; Const max=30000; Var n,i,l,now,head:longint; p:array[1..max]of boolean; x,y,m,q,w,k:array[1..max]of longint; Function check(f,u:longint):longint; var a,b,c:longint; begin a:=sqr(x[f])+sqr(y[f]); b:=sqr(x[u])+sqr(y[u]); c:=sqr(x[f]-x[u])+sqr(y[f]-y[u]); if (a+b-c)>sqrt(a*b) then exit(1) else if(a+b-c)<=-sqrt(a*b) then exit(2) else exit(3); end; Procedure back(u:longint); begin if q[u]=0 then begin p[u]:=not p[u]; exit; end; back(q[u]); back(w[u]); end; Procedure change_mod1(a,b:longint); begin inc(head); x[head]:=x[a]-x[b]; y[head]:=y[a]-y[b]; q[head]:=m[a]; w[head]:=m[b]; m[head]:=head; back(w[head]); end; Procedure change_mod2(a,b:longint); begin inc(head); x[head]:=x[a]+x[b]; y[head]:=y[a]+y[b]; q[head]:=m[a]; w[head]:=m[b]; m[head]:=head; end; Procedure exchange(a,b:longint); var u:longint; begin u:=x[a]; x[a]:=x[b]; x[b]:=u; u:=y[a]; y[a]:=y[b]; y[b]:=u; u:=m[a]; m[a]:=m[b]; m[b]:=u; u:=m[a]; m[a]:=m[b]; m[b]:=u; u:=q[a]; q[a]:=q[b]; q[b]:=u; u:=w[a]; w[a]:=w[b]; w[b]:=u; end; Function checkzero(u:longint):boolean; begin if (x[u]=y[u])and(y[u]=0) then exit(true) else exit(false); end; Begin {assign(input,'1130.in'); reset(input); assign(output,'1130.out'); rewrite(output); } readln(n,l); head:=n; now:=1; for i:=1 to n do begin readln(x[i],y[i]); p[i]:=true; m[i]:=i; end; while head>1+now do begin if checkzero(now) then begin inc(now); continue; end; if checkzero(now+1) then begin inc(head); x[head]:=x[now]; y[head]:=y[now]; m[head]:=m[now]; inc(now,2); continue; end; if checkzero(now+2) then begin inc(head); x[head]:=x[now]; y[head]:=y[now]; m[head]:=m[now]; inc(now); inc(head); x[head]:=x[now]; y[head]:=y[now]; m[head]:=m[now]; inc(now,2); continue; end; case check(now,now+1) of 1:change_mod1(now,now+1); 2:change_mod2(now,now+1); 3:case check(now,now+2) of 1:begin change_mod1(now,now+2); // exchange(now+1,now+2); inc(now); inc(head); x[head]:=x[now]; y[head]:=y[now]; m[head]:=m[now]; end; 2:begin change_mod2(now,now+2); inc(now); inc(head); x[head]:=x[now]; y[head]:=y[now]; m[head]:=m[now]; end; 3:case check(now+1,now+2) of 1:begin change_mod1(now+1,now+2); inc(head); x[head]:=x[now]; y[head]:=y[now]; m[head]:=m[now]; inc(now); end; 2:begin change_mod2(now+1,now+2); // exchange(now,now+2); inc(head); x[head]:=x[now]; y[head]:=y[now]; m[head]:=m[now]; inc(now); end; end; end; end; inc(now,2); end; if sqr(x[now]+x[head])+sqr(y[now]+y[head])>sqr(l) then back(m[head]); writeln('YES'); for i:=1 to n do if p[i] then write('+') else write('-'); close(output); End. |
| It drives me crazy! | yuyan | 1579. Coat Transportation | 26 Mar 2009 12:27 | 3 |
What's the test 15?Can somebody tell me? Thank you. Here is my code with O(N) soulution which is get WA on #15 program coats; const maxn=200100; var g,next,t:array [0..maxn] of int64; l,a:array [0..maxn] of int64; i,k,m,n:longint; r:int64; procedure init; begin read(n,r); for i:=1 to n do read(a[i]); end; procedure solve; begin m:=1;k:=1; next[n]:=g[1];g[1]:=n;l[1]:=a[n];t[1]:=1; for i:=n-1 downto 1 do begin if l[k]-a[i]>r then begin next[i]:=g[k];g[k]:=i;l[k]:=a[i];inc(t[k]); inc(k);if k>m then k:=1; continue; end; inc(m);next[i]:=g[m];g[m]:=i;l[m]:=a[i];t[m]:=1; end; writeln(m); for i:=m downto 1 do begin write(t[i]); r:=g[i]; while r<>0 do begin write(' ',r); r:=next[r]; end; writeln; end; end; begin assign(input,'coats.in');reset(input); assign(output,'coats.out');rewrite(output); init; solve; close(input);close(output); end. Nothing serious.Just a big and hidden mistake in my program. Thank you anyway. |
| Would you like to do me a favor to post me a copy of testing data? | orlando22 | 1129. Door Painting | 26 Mar 2009 10:17 | 1 |
Thanks a lot! I need to analyize why my algorithm is wrong!I use forward-star to construct Graph, and Euler circuit algorithm. unfortunately, still the prompt "Wrong answers" |
| i think sample test case in given problem is wrong | Anupam Ghosh,Bengal Engg and Science University,Shibpur,India | 1064. Binary Search | 25 Mar 2009 21:39 | 3 |
take N=29 p=0 q=28 i=14 L=1 p=15 q=28 i=21 L=2 p=21 q=28 i=24 L=3 this is cancelled since i value is not 10 NOW the other way p=0 q=28 i=14 L=1 p=0 q=13 i=6 L=2 p=0 q=5 i=2 L=3 this is cancelled since i value is not 10 can any body explain me this?? take N=29 p=0 q=28 i=14 L=1 p=15 q=28 i=21 L=2 p=22 q=28 i=25 L=3 this is cancelled since i value is not 10 NOW the other way p=0 q=28 i=14 L=1 p=0 q=13 i=6 L=2 p=0 q=5 i=2 L=3 this is cancelled since i value is not 10 can any body explain me this?? Answer - is a POSSIBLE value of N. It means, that from this value you CAN get I for L steps. P = 0 Q = 28 I = 14 L = 1 P = 0 Q = 13 I = 6 L = 2 P = 7 Q = 13 I = 10 L = 3 |