Why if there is no answer, we should print "5"? It must be included in problem description!!! Not 5, but we should add 30 minutes to difference we seek for. For instance, we've found "2H=9", what is unbelievable, 'cause it contradict the statement. But I increment this to get the even number 10=2*5. Answer: 5 hours. I still don't know why is it true. Update. I've just found my mistake. The tests are OK (but method of "increment" also works). Edited by author 07.08.2011 16:57 I not used any equations. I bruteforced through all possible differences, and if answer was not found then I was printing "5" (by advices from forum). Problem description is correct. Try this test: 01.01 21.59 04.23 09.22 Answer:4 But I think your solution will print 5 because of this condition. So people who got AC for this problem using this condition solved it incorrectly. Edited by author 23.10.2013 01:14 Edited by author 23.10.2013 01:14 I also tried bruteforce and on test 2 my program finds that there is no valid answer. However, if I just return 5 in case of failure program gets acc. I'd really like to know what test 2 is. By the way, my program outputs the correct answer on the test above. Try this test: 01.01 21.59 04.23 09.22 Answer:4 Pozhaluysta, kto-nibud', dayte mne hot' kakie testy k zadache 1070! A to vse testi, kotoriye u menya yest' moya programma prohodit, no na teste #1 dayot nepravil'niy otvet! I obyasnite, pochemu mozhet byt' test: "12.00 15.00 01.02 03.07 Answer: 0" ? Yes you Answer 0; 1) 23.42 01.14 08.10 17.51 Answer: 4 2) 01.01 10.59 04.23 04.22 Answer: 5 3) 12.00 15.00 01.02 03.07 Answer: 0 4) 23.58 00.43 22.27 03.10 Answer: 2 5) 12.00 15.00 20.00 21.00 Answer: 1 6) 01.01 21.59 04.23 11.22 Answer: 5 Yes you Answer 0; 1) 23.42 01.14 08.10 17.51 Answer: 4 2) 01.01 10.59 04.23 04.22 Answer: 5 3) 12.00 15.00 01.02 03.07 Answer: 0 4) 23.58 00.43 22.27 03.10 Answer: 2 5) 12.00 15.00 20.00 21.00 Answer: 1 6) 01.01 21.59 04.23 11.22 Answer: 5 Can you explain me why on test 6 -> answer is 5 ? Edited by author 28.12.2006 20:13Please, explain me why the answer is 5? answer is 5, because max difference in time = 5 hours)) then all answers >5 , =5 ! Edited by author 28.09.2009 21:26 There should be min(12 - h, h) instead of min(h, 5), test: 01.00 00.00 00.00 03.00 Answer 2 my programe can pass all your tests#,but i WA at ural's test#1,why...? does someone can help me? #include <stdio.h> main() { int i,j,k;
scanf("%lf%lf%lf%lf",&ch[1],&ch[2],&ch[3],&ch[4]); for(i=1;i<=4;i++) { time1[i]=(int)ch[i]; time2[i]=ch[i]-time1[i]; if((i==2 || i==4) && time1[i]<time1[i-1]) time1[i]+=24; } hour=time1[3]-time1[4]+time1[2]-time1[1]; mini=time2[3]-time2[4]+time2[2]-time2[1]; hour=abs(hour+mini*5.0/3.0); hour/=2; if(hour>5) hour=5; printf("%.0lf",hour); } test 3 is wrong. please, read the statement. The time of flights there and back may differ from each other not more than by 10 minutes if answer is one, the time of the first flight is 3 hours and the second - 2 hours 5 minutes... of course, those times differ by 55 minutes... Potomu chto okruglyaetcya do nulya (chisla celye) Kstati ya poluchil AC no u menya bolshaya proga. Kto-nibud mojet obyacnit kak cdelat koroche? [code deleted] Edited by moderator 29.12.2006 09:12 I have got WA at test 4,but I don't know why,I have debug my code for the whole afternoon,could you please give me some helpful tests? 01.01 21.59 04.23 11.22 Answer: 5 12.00 15.00 20.00 21.00 Answer: 1 23.58 00.43 22.27 03.10 Answer: 2 12.00 15.00 01.02 03.07 Answer: 0 01.01 10.59 04.23 04.22 Answer: 5 23.42 01.14 08.10 17.51 Answer: 4 On 4th your test my AC programm returns 143165577 O_o So this test is incorrect :) my AC program gives 0 did you use unsigned?? "The difference between airport local times is not greater than 5 hours". This means that if you get an answer > 5, you should output 5 (it's stupid, i know). Got several WA6 before i realized it Edited by author 05.09.2008 15:33 yeah really.....thanx so much...Even I got WA6 for this stupid reason. I also had WA#2 for the same reason. I think that there is a mistake in problem statement. If you got Wrong answer 6 then if (answer>5) answer=5; cout<<answer -- !!! Most Important!!! I have got AC when write it. Example 01.01 21.59 04.23 11.22 Answer: 5 true 7 hours (21-7=7+7), but you must write 5!!! good luck. :) I think you are not right. In this test the time difference between two airports is exaclty 5, and the flying lasts 2 hours. So, the first difference ~ -3 hours, and the second one ~ 7 hours. It's true)) There is a inconsistent problem situation. They should write date of flight. Sorry for my english. Double post. Wrong! please delete this post. Edited by author 23.07.2010 02:19 Edited by author 23.07.2010 02:19 Where is Greenpeace? Oh,rebits,rebits... Before sending solution, just test it on this examples. 1) 23.42 01.14 08.10 17.51 Answer: 4 2) 01.01 10.59 04.23 04.22 Answer: 5 3) 12.00 15.00 01.02 03.07 Answer: 0 4) 23.58 00.43 22.27 03.10 Answer: 2 5) 12.00 15.00 20.00 21.00 Answer: 1 6) 01.01 21.59 04.23 11.22 Answer: 5 ;) Thank you very much!!!! I've got AC!! HAHA!! Before sending solution, just test it on this examples. 1) 23.42 01.14 08.10 17.51 Answer: 4 2) 01.01 10.59 04.23 04.22 Answer: 5 3) 12.00 15.00 01.02 03.07 Answer: 0 4) 23.58 00.43 22.27 03.10 Answer: 2 5) 12.00 15.00 20.00 21.00 Answer: 1 6) 01.01 21.59 04.23 11.22 Answer: 5 ;) Thanks a lot! It helps me very much. I don't usually plan before writing a program, so I made lots and lots of wrong algorithms. I use your test cases and I correct , correct and recorrect my algorithms. They are wrong and wrong on test 4, 2, 5,.. (your test cases). And I got AC on the 2nd submit! Thank you! 6) 01.01 21.59 04.23 11.22 Answer: 5 why it is true? what is wrong in my& my program: var xh1, xh2, yh1, yh2 : real; xm1, xm2, ym1, ym2 : real; k, km : longint; begin read(xh1, yh1, xh2, yh2); xm1:=trunc(xh1*100) mod 100; xm2:=trunc(xh2*100) mod 100; ym1:=trunc(yh1*100) mod 100; ym2:=trunc(yh2*100) mod 100; if yh1<xh1 then yh1:=yh1+24; if yh2<xh2 then yh2:=yh2+24; xh1:=trunc(xh1); xh2:=trunc(xh2); yh1:=trunc(yh1); yh2:=trunc(yh2); k:=abs(trunc(0.5*(yh1-yh2+xh2-xh1+trunc( (ym1-ym2+xm2-xm1)/60) )) ); writeln(k); end. Thank you a lot. In your test 6 my program outputs 7. I forgot that answer should be than 6. But due to my formula (which,I hope, is correct)the answer is 7. Now I have AC. Thanks! I couldn't get 1 thing for tests 2 and 6. why answer isn't 7? if the real time of flight if 17, for 2 test and 14, for 6 test, then 17-7=10 and 14-7=7 (the differences of flights where time is "going back") and 17+7=24 & 14+7=21 (the differences of flights where time is "goting forward"). but if answer is 5 then 10+5=15 24-5=19 (<>) and 7+5=12 and 21-5=16. then wahy this test are true. I know that there must be something that I didn't saw so please help me. thanks. I'm don't understand, how can it be: 12.00 15.00 01.02 03.07 It means, that in one way plane fly 3 hours, in other - 2 hours. But in terms said, that times differs not more than 10 minutes. This test is INCORRECT! Read this post again. program a_local_time_1070; {$APPTYPE CONSOLE} { 1070 Pascal } var to1,to2,tp1,tp2:real; min1,min2:integer; dd1,dd2,dd:integer; arrpl:array[1..6] of boolean; cou:integer; function dif(t1,t2:real):integer; var st1,st2,st3,st4:integer; m:boolean; diff:integer; begin m:=false; diff:=0; st1:=trunc(t1); st2:=trunc((t1-st1)*100); st3:=trunc(t2); st4:=trunc((t2-st3)*100); if (st1=st3) and (st2=st4) then m:=true; while m=false do begin inc(diff); inc(st2); if st2=60 then begin inc(st1); st2:=0; end; if st1=24 then begin st1:=0; end; if (st1=st3) and (st2=st4) then m:=true; end; dif:=diff; end; begin readln(to1,tp1); readln(to2,tp2); dd1:=dif(to1,tp1); dd2:=dif(to2,tp2); if dd1<dd2 then for cou:=1 to 6 do begin min1:=60*cou+dd1; min2:=dd2-60*cou; if (min1-min2>-11) and (min1-min2<11) then arrpl[cou]:=true; end else for cou:=1 to 6 do begin min1:=60*cou+dd2; min2:=dd1-60*cou; if (min1-min2>-11) and (min1-min2<11) then arrpl[cou]:=true; end; for cou:=1 to 6 do if arrpl[cou]=true then dd:=cou; writeln(dd); end. ME TOO I DON'T KONW WHY. I CAN'T UNDERSTAND... {$APPTYPE CONSOLE} var t1,t2,t3,t4: real; a1,a2,a3,a4: integer; k1,k2: integer; diff1, diff2: integer; i: integer; begin Assign(input,'input.txt'); reset(input); Assign(output,'output.txt'); rewrite(output); readln(t1,t2); read(t3,t4); if t1 > t2 then t2 := t2 + 24; if t3 > t4 then t3 := t3 + 24; a1:=round(t1)*60; a2:=round(t2)*60; a3:=round(t3)*60; a4:=round(t4)*60; if (t1-trunc(t1))>0.09 then a1:=a1 + round((t1-trunc(t1))*100) else a1:=a1 + round((t1-trunc(t1))*10); if (t2-trunc(t2))>0.09 then a2:=a2 + round((t1-trunc(t1))*100) else a2:=a2 + round((t2-trunc(t2))*10); if (t3-trunc(t3))>0.09 then a3:=a3 + round((t3-trunc(t3))*100) else a3:=a3 + round((t3-trunc(t3))*10); if (t4-trunc(t4))>0.09 then a4:=a4 + round((t4-trunc(t4))*100) else a4:=a4 + round((t4-trunc(t4))*10); for i:=0 to 5 do begin diff1 := a1-i*60; diff2 := a4-i*60; k1:= abs(abs(diff1-a2)); //writeln(k1 div 60,':',k1 mod 60, ' ',diff1,'-',a2,' ', abs(diff1-a2)); k2:= abs(abs(diff2-a3)); //writeln(k1 div 60,':',k1 mod 60, ' ',diff2,'-',a3,' ', abs(diff2-a3)); //writeln(diff1 div 60,':', diff1 mod 60, ' ', t2:2:2); //writeln(t3:2:2,' ',diff2 div 60,':', diff2 mod 60); if abs(k1-k2)<=10 then writeln(i); end; end. Just use a simple math calculation, it's pretty easy.. Edited by author 22.08.2008 12:20 pening lah arbi..............! how can i get AC var t1, t2, t3, t4 : real; a1, a2, a3, a4, x : integer; begin readLn(t1, t2); read(t4, t3); if t1 > t2 then t2 := t2 + 24; if t4 > t3 then t3 := t3 + 24; a1 := TRUNC(t1); a2 := TRUNC(t2); a3 := TRUNC(t3); a4 := TRUNC(t4); t1 := (t1-a1)*5/3 + a1; t2 := (t2-a2)*5/3 + a2; t3 := (t3-a3)*5/3 + a3; t4 := (t4-a4)*5/3 + a4; x := TRUNC(abs(t1-t2+t3-t4)/2); writeLn(x); end. var as,be,bs,ae:real; procedure init; begin readln(as,be); readln(bs,ae); end; procedure ik; var I,J:integer; flytime1,flytime2:real; begin for I:=-5 to 5 do begin if be-i<as then be:=be+24; flytime1:=(be-i)-as; if ae<bs-i then ae:=ae+24; flytime2:=ae-(bs-i); if abs(flytime1-flytime2)<1/6 then begin write(abs(I)); halt; end; end; end; begin init; ik; end. but how many reserved words? main,as,try....... and, array, as, asm, begin, case, class, const, constructor, destructor, dispinterface, div, do, downto, else, end, except, exports, file, finalization, finally, for, function, goto, if, implementation, in, inherited, initialization, inline, interface, is, label, library, mod, nil, not, object, of, or, out, packed, procedure, program, property, raise, record, repeat, resourcestring, set, shl, shr, string, then, threadvar, to, try, type, unit, until, uses, var, while, with, xor plz read FAQ before asking such questions... input: 23.42 01.14 08.10 17.51 my output is 9 The differ of the two airport is -4 hours. So the time as the destination local time is below: 23.42-4=19.42 01.14=25.14 08.10 17.51-4=13.51 first duration is 25.14-19.42=5.32 second duration is 13.51-08.10=5.41 so the answer is 5.41-5.32=9 Is it right?? Thanks My ACed problem show that the answer is 4 Can you tell me the difference between the two airports' local time? thanks for your reply. I dont get it: why the answer for the test 01.01 21.59 04.23 11.22 is 5? Because 01.01 2.59 09.23 11.22 Time of flying 2 hourse var at,be,bs,ae:real; procedure init; begin readln(at,be); readln(bs,ae); end; procedure ik; var I,J:integer; flytime1,flytime2:real; begin for I:=-5 to 5 do begin if be-i<at then flytime1:=(be+24-i)-at else flytime1:=be-i-at; if ae<bs-i then flytime2:=ae+24-(bs-i) else flytime2:=ae-(bs-I); if abs(flytime1-flytime2)<1/6 then begin write(abs(I)); halt; end; end; end; begin init; ik; end. Is it always a solution? If not, what should I print? Yes. NO, not at all. Try Test #3 from DWED's "HINT": 12.00 15.00 01.02 03.07 Answer: 0 |
|