| Show all threads Hide all threads Show all messages Hide all messages |
| I am overcounting...not sure where..help? | Gokul | 1009. K-based Numbers | 14 Jan 2013 18:37 | 1 |
Hi, I am just beginning to write code although i am bit familiar with algorithms and datastructures. I wrote this solution. But its wrong. I kinda feel that i am overcounting but not sure where it is. if( n == 0) return 1; if(n == 1) return k-1; return k-1 * ( k * f(n-2,k) + k * k-1 * f(n-3,k) ) if digit n-1 can have zero there are k ways we can fill it, hence k * f(n-2,k) else if digit n-1 cannot have zero then we can use k-1 ways for digit n-1 and k ways for n-2. Edited by author 14.01.2013 18:41 |
| Help please!WA#25 | Sasha | 1348. Goat in the Garden 2 | 14 Jan 2013 01:55 | 2 |
#include <stdio.h> #include <math.h> int ax,ay,bx,by,cx,cy,l; double AB,AC,BC,p,h,mas[3],tmp; int main(){ scanf("%d%d%d%d%d%d%d",&ax,&ay,&bx,&by,&cx,&cy,&l); AC=sqrt(pow(ax-cx,2.0)+pow(ay-cy,2.0)); AB=sqrt(pow(ax-bx,2.0)+pow(ay-by,2.0)); BC=sqrt(pow(bx-cx,2.0)+pow(by-cy,2.0)); p=(AB+BC+AC)/2; h=((sqrt(p*(p-AB)*(p-BC)*(p-AC))*2)/AB)-l; AC=AC-l; BC=BC-l; if(AC<0) AC=0; if(BC<0) BC=0; if(h<0) h=0; mas[0]=AC; mas[1]=BC; mas[2]=h; for(int i=0;i<3;i++){ for(int j=i+1;j<3;j++){ if(mas[i]>mas[j]){ tmp=mas[i]; mas[i]=mas[j]; mas[j]=tmp; } } } if(((ax!=bx) && (ay!=by) || (0-ax!=bx) && (0-ay!=by)) && (ax<cx && bx>cx) || (ax>cx && bx<cx) || (ay<cy && by>cy) || (ay<cy && by>cy)) printf("%.2f\n%.2f",mas[0],mas[2]); else { if(BC<AC) { tmp=AC; AC=BC; BC=tmp; } printf("%.2f\n%.2f",AC,BC); } } |
| 1930 :: Help Please | Bristy | 1930. Ivan's Car | 13 Jan 2013 21:12 | 1 |
My solution is a BFS using deque, but i am gettign WA 4. Please Help me someone... |
| No subject | Majo | 1944. Record of the Attack at the Orbit | 13 Jan 2013 19:30 | 1 |
Edited by author 13.01.2013 19:42 Edited by author 13.01.2013 19:42 |
| What is the answer for this test? | Borozdin Kirill | 1715. Another Ball Killer | 13 Jan 2013 19:07 | 2 |
UPD: At last I got AC, there was just a really stupid bug. Wrong output is replaced with correct one produced by my AC solution. Please, anybody who has AC solution, check my solution's answer for this big random test: INPUT 50 50 GRYBYYWWRYBBGRGGBRRGGYRWRRGGWBRGGWYRRYBYWGRWWYGGWW RYRRRYWGYWGBBRWGBRYWGBBYBBGGWWYWYYGBGGGWYYGWRWWRYG WBYWYBRGWGGBYRBYRWRRGBGGBRBYGRBBGYGBRGRRRRWWBYYWGW RGGBWWBGRBBYYRWWBGRBGGYBGGWYWYGYWYWWBWRRWWWWRGBRWY YGBGBYYGWWYWYYYRBBWWWRYWWBWWBGWGYWYRRRWRWYBRWGBWGG RYRBWGRGBWYRYGGWRGGYRGRYBRBBWYGWGYBWRBRBWGRRRRYYGY GYWRBBYYGRBBWWYWYGRYYRGYWBRGGBWRBYYGGGGWWBBWRWRBWG GWGRGYGRYGBBWGYYRYWYYBBYGWYRWWRBWGRBRYYYYYRYWBRRWR WBWWRBRBWRRYRBWYWRGGWRBWBGRRRGYBRBWYBBBWGBGRBBBYBY YBGYWRGGWWGYWYYRBRBGBRBBGRWWYYRGBRRYBRYWWBRRWGRGBB YBRGBGGGGRWBBYWWBGRYBWWWBRRBWYWBRYRWWRGBBWWYBBGYBG RBWBGGGRGRRGYGGRRRRGBGWYYBYRGBWRYYYRRYRWRWGBRWBWWR YGGBYBGBGYBWBWYGWYRYGWGBRWGBWGBBRRGRYWRWGWBWBRWBRR RBYGBWBBRYBBWYGBYWBYRBYGWYBWRRYGGRRGYBWYGRBWWRYGRY BWRYBGWBRRYWGWGWBGYBYRYWGYWRBBBYWRWRYWGYWBBRGWYRYB YYBBBWWBGWRRRRBWGWWRBYBBWWRWWRYWYGWRWBGWYWGBYWB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WGBBYBBBGBBGWYGRRBBBRBRBGRRWB BGWWBGYWRBBRBRBGGWGWBGBYRGBRWRGRRWWWRYBBBYYBWBYYBG GGRWWYRRWWBYWYWYRYYBBRYRGGWBYBWBGBGBWYBWYGRBRGWWBY WBRBGBRRYYGRWBRWWYRWWYGWBYGRRRGWGWGBGBBBGRRGBBWWYR WYRRBWYBYYYWBWYGBWWYBGRBBGBYWWBRYBYWRYBRWBYGGGYBRY GRYYYWRGBWRWYRRGGBBGWRGBBRYYYBGGGYBYRGYRBYWWWGWBGY BYWWWYBGWGRWWGYWGWWYWYRRRGRGGRWBGBRBGBRRBYBYWRBGBW WGBRBRYRWRRRYWGWWGBGWRGBGRYBGGBYGWWBBYRGWWBRYBYWBR WWBWBWRGGBWGWRRWYRWBRWRBBWGRYYWWRRGRYBBWYBGBWYRWRY YYRYYBYYYWBWRWBGRGYWWWRYWWRWWYBRBGRGBRGGWBBWWYBRWR RRBBRWGGWRRRWRYBYRYGWBWGYRBRYRBWGBBRGGYWBWRWBYWRWG BRRRGWBRBWGWGYBGGBGBYRWBWGBGRGRYYYWBBGWBBWYRWBWBGY RWGGGWBWGBRGBRWWBBGGYYWWWRWWRWBGYWRWYWYRYGYBWYGYWW GYGYBRGWYGWWWYRRWYBGYBRWYYYBGWYWYYRBWYBGYWGRBBGBGG OUTPUT B: 43900 G: 47932 R: 26046 W: 38176 Y: 21310 Am I correct? Edited by author 14.02.2012 18:03 Edited by author 14.02.2012 18:03 |
| WA# 4 | IgorKoval [PskovSU] | 1715. Another Ball Killer | 13 Jan 2013 19:01 | 1 |
WA# 4 IgorKoval [PskovSU] 13 Jan 2013 19:01 3 3 WYY YWR WYR answer: R: 4 W: 12 Y: 8 I am good man! In promlem it is said that: "05 If there is a figure of the main color:" But I have wrote in my program: "WHILE there is a figure of the main color:" Stupid bug! =) Edited by author 13.01.2013 19:05 |
| Test # | Ioannis Hikari | | 13 Jan 2013 16:34 | 1 |
Test # Ioannis Hikari 13 Jan 2013 16:34 What does the number under column Test # mean? |
| correct algo is not logical!!! | kunal | 1009. K-based Numbers | 13 Jan 2013 14:49 | 2 |
can anybody explain to me why f[0]=1????....i mean it's logically wrong....but the algo is giving AC with these assumption.... It's NOT logically wrong. Learn more math and then you'll understand it. |
| (to anyone who got AC): Is "NO SOLUTION" impossible for your AC? | Locomotive | 1128. Partition into Groups | 13 Jan 2013 01:48 | 18 |
You asked if "No solution" is impossible. My answer was yes. So I'm saying that such a test doesn't exist. +^^+ Locomotive 8 Mar 2003 16:58 Thanks! it was matter of bad English for such an Iranian Boy... Can you help me a little bit more? which algorithm i should use? DFS and BFS dont help... Brute Force doesn`t seem beauty ;)! Please Help Me Best Aidin_n7@hotmail.com First put every child into the first team. Then while there exists a child who has more than one opponent in his team, just move him to the other team. I don't know how. Could you explain it for me? Thank you very much! Can you give me a code, plz? The idea really works. But did you prove that this algo is correct? (Why will it finish the work in a finite number of steps?) It works because in each step number of edges between the two parts increases and obviously it can't be more than E. This proof incomplete and doesn't shed light to the point. We should add next: if person Q on the left side have >=2 enemy on the left then he don't have more than 1 enemies in persons on the right because in other case he would have >=4 enemies. Edited by author 26.11.2011 08:42 It is clear that if proposed algorithm terminates then we have found a solution. But does it allways terminate? I will try to add my 5 cents by giving a short yet complete proof of termination. Let us first introduce the decreasing measure M. We define M to be equal to the number of edges of the graph on the same(!) side. Algorithm terminates if measure decreases with each iteration of algorithm. Let us consider 3 possible situations: 1) We change side of a child with 3 enemies on his side. Then M decreases by 3. 2a) We change side of a child with 2 enemies on his side and 0 enemies on other side. Then measure decreases by 2. 2b) We change side of a child with 2 enemies on his side and 1 enemy on other side. Then M decreases by 2 and increases by 1. 3) If child has only one enemy on his side, then we do nothing. According to described cases M will decrease after each iteration. Hence, algorithm terminates. Hope this helps :) Edited by author 27.03.2006 01:16 |
| I'm getting insane!!!now wa#2, althought I've tested it whit an AC program | Tusnad Nobrovirski | 1306. Sequence Median | 12 Jan 2013 14:19 | 5 |
here is my code. please help me :(( #include <stdio.h> #define HMAX (1<<17) int N; unsigned int H[HMAX]; void sift(int x) { int aux, up = x>>1; if (x < 1) return; if (H[x] > H[up]) { aux = H[x]; H[x] = H[up]; H[up] = aux; sift(up); } } void perc(int x, int n) { int l = x<<1, r = (x<<1)+1, max, aux; if (r > n) return; max = l; if (H[l] < H[r]) max = r; if (H[max] > H[x]) { aux = H[max]; H[max] = H[x]; H[x] = aux; perc(max, 1+N/2); } } int main() { int i, val; long double sol; unsigned int last, blast; // freopen("1306.in", "r", stdin); scanf("%d", &N); H[0] = 4294967295; for (i = 1; i <= 1+(N/2); i++) scanf("%lu", H+i); for (i = 1; i <= 1+(N/2); i++) sift(i); for (i = 2+(N/2); i <= N; i++) { scanf("%d", &val); if (val < H[1]) { H[1] = val; perc(1, 1+(N/2)); } } blast = H[1]; H[1] = 0; perc(1, (N/2)); last = H[1]; sol = last*0.5; sol += blast*0.5; if ( (N&1) == 0 ) printf("%0.1llf\n", sol); else printf("%u\n", blast); return 0;
} Try test with n=2. FE 2 10 20 The result of my Program is 15.0 How about you ?? In my opinion, test #2 contain data like this: 1 5 Correct answer is: 5.0 I had a problem with output format. We should output the answer with one decimal digit after decimal point. My wrong program had written: 5 without fractional part. |
| k1 k2 k3 range from 0.01 to 100?? | Mickkie | 1582. Bookmakers | 12 Jan 2013 09:59 | 1 |
from the betting coefficient k is (m + n) / n I think k must be greater than 1. Don't you think so? |
| test 6 | Majo | 1915. Titan Ruins: Reconstruction of Bygones | 11 Jan 2013 21:21 | 1 |
What is test 6? Edited by author 11.01.2013 21:21 |
| Test #16 | panLevan | 1106. Two Teams | 10 Jan 2013 09:39 | 1 |
Can somebody give test #16? Getting TLE Thnx |
| Hint | TakeOver | 1430. Crime and Punishment | 10 Jan 2013 01:07 | 1 |
Hint TakeOver 10 Jan 2013 01:07 when you search x and y (A*x+B*y = N) use something like this for x:= 0 to min(n div a, trunc(sqrt(n))) do =) |
| yet another note for WA4 | Aneto | 1252. Sorting the Tombstones | 9 Jan 2013 02:21 | 1 |
if stones are sorted then answer is n-1 It took me a while to find out this special case :) |
| very bad problem | amirani | 1873. GOV Chronicles | 8 Jan 2013 11:17 | 4 |
this is very bad problem :( |
| If you get Crash (access violation) | Berendea | 1019. Line Painting | 8 Jan 2013 05:48 | 1 |
Try the following test: 50 3081 30488 b 16217 39416 w 7248 11364 w 17676 32492 w 25292 30974 w 1686 28199 w 9576 25807 w 18823 21457 w 30775 38642 w 7758 15847 b 6289 19805 b 1546 26246 w 27602 30148 w 9296 14836 w 19435 26471 w 27882 35227 w 24453 42158 w 943 1752 b 4080 12268 w 31529 41419 w 6238 22445 w 6262 13797 w 16616 31697 w 9990 12426 w 31675 46085 w 15149 32698 b 16029 18700 b 32372 50450 w 19642 25152 b 21096 30699 b 27244 35134 b 29951 43374 w 8869 9499 w 3375 28256 w 2060 14099 b 19972 37822 b 30222 33297 b 5433 9482 w 28735 54469 b 19053 31004 w 12234 27889 b 19117 19750 b 11927 17069 w 30056 32152 b 21756 25680 w 25656 44214 b 5308 18661 b 21710 26158 b 9196 32476 b 9917 11034 b I don't know what the output is. Mine was 54496 1000000000 |
| Interesting :-) | ftc | 1632. Lasers | 8 Jan 2013 02:47 | 3 |
Nice to see, but "higher" relation is not transitive ;-) It is very easy problem, but why only 54 people solved?! This problem has simple solution and very interesting, but not obvious idea... |
| How to use reals with range 10^18 in pascal? | Shohruh | 1948. The Robot on the Line | 7 Jan 2013 01:19 | 4 |
can anybody explain me how to use reals with big range like 10^18 or 10^19 more precisely in pascal? If you need real numbers with best affordable precision - use long double ("extended" in pascal). Edited by author 06.01.2013 23:12 I knew the solution was k=1 or trunc((1+12*b*b/(a*a)-3*c/a)). but i could not take precision. If you need real numbers with best affordable precision - use long double ("extended" in pascal). F**k, spoiler =( Then you don't need real numbers here - long long (int64 in Pascal) is enough to solve it |
| Test 3 crash - floating-point invalid operation | SemenB | 1209. 1, 10, 100, 1000... | 7 Jan 2013 00:51 | 1 |
Please help Why am I getting floating-point invalid operation on test 3? Would it be possible to see the test values? program pr_1; var n, i, x: longint; a: real; begin read(n); for i:=1 to n do begin read(x); a:= (1 + sqrt(8*x-7))/2; if (Frac(a) = 0.0) then write('1 ') else write('0 '); end; end. |