Common Board| Show all threads Hide all threads Show all messages Hide all messages | | I used Greedy and got AC.By the way,why the AC rate is so high? | Yu YuanMing | 1129. Door Painting | 1 Aug 2008 14:40 | 2 | If your greed is chain-based, then it's correct Edited by author 01.08.2008 14:40 | | Is that Possible& | Piratek-(akaDK) | 1129. Door Painting | 1 Aug 2008 14:39 | 2 | Может ли быть между двумя комнатами больше чем одна дверь? (Can there exist more than 2 doors between rooms?) No because numbers of adjacent rooms are ASCENDING. | | problem 1129 | tyana | 1129. Door Painting | 1 Aug 2008 14:38 | 5 | Whether in a problem 1129 some variants of the answer are possible?? In that case my answer will not converge at check. Or here such situations are provided? Some checkers are smarter than just identity | | How to avoid TLE in Test#10? | Nickolas Kakà | 1129. Door Painting | 1 Aug 2008 14:37 | 2 | How to avoid TLE in Test#10? Solution is O(M), M - number of doors | | Test 4 WA =( | KantSU: Vashegin Roman | 1561. Winnie the Pooh | 1 Aug 2008 13:41 | 1 | | | how to deal with the stack overflow? | chinaeli | 1001. Reverse Root | 1 Aug 2008 12:21 | 1 | #include<iostream> #include<cmath> using namespace std; void solve ( double a ) { double b; while ( cin>>b ) solve(b); printf("%.4lf\n",sqrt(a)); } int main ( ) { double a; cin>>a; solve(a); } | | Need help. Look over my code or give some tests please. | Akshin Salimov | 1348. Goat in the Garden 2 | 1 Aug 2008 10:47 | 12 | Please help me, look over my code, I'll be thankfull to anyone who will find mistake in my code, or give me some tests. var h,s,aa,bb:real; a:array[1..3,1..2] of integer; i,l:integer; procedure readdata; begin readln(a[1,1],a[1,2],a[2,1],a[2,2]); readln(a[3,1],a[3,2],l); end; procedure writedata; begin writeln(aa:0:2); writeln(bb:0:2); end; function d(x1,y1,x2,y2:integer):real; begin d:=sqrt(sqr(x1-x2)+sqr(y1-y2)); end; procedure square; var p,a1,a2,a3:real; begin a1:=d(a[1,1],a[1,2],a[2,1],a[2,2]); a2:=d(a[3,1],a[3,2],a[2,1],a[2,2]); a3:=d(a[1,1],a[1,2],a[3,1],a[3,2]); p:=(a1+a2+a3)/2; s:=sqrt(p*(p-a1)*(p-a2)*(p-a2)); end; begin readdata; square; h:=d(a[1,1],a[1,2],a[2,1],a[2,2]); aa:=s/(0.5*h); if d(a[1,1],a[1,2],a[3,1],a[3,2])<aa then aa:=d(a[1,1],a[1,2],a[3,1],a[3,2]); if d(a[2,1],a[2,2],a[3,1],a[3,2])<aa then aa:=d(a[2,1],a[2,2],a[3,1],a[3,2]); bb:=d(a[3,1],a[3,2],a[2,1],a[2,2]); if d(a[3,1],a[3,2],a[1,1],a[1,2])>bb then bb:=d(a[3,1],a[3,2],a[1,1],a[1,2]); if (s/(0.5*h))>bb then bb:=(s/(0.5*h)); aa:=aa-l; bb:=bb-l; writedata; end. SEE Виктор Крупко 12 Apr 2005 22:57 2 1 4 2 0 0 1 YOUR: -1.00???? 3.47 AC: 1.24 3.47 What do you think how it can be changed? :):):):):):):):):):):):):):):)+++++++++++++++++++++ I'm not talking about decision, decision is right. I said that how code can be changed to get AC? I modified my code, it gives correct answer for your test but i still get this ****** WA#4 !!! Here is code var a1,a2,a3,h,s,aa,bb:real; a:array[1..3,1..2] of integer; i,l:integer; procedure readdata; begin reset(input);} readln(a[1,1],a[1,2],a[2,1],a[2,2]); readln(a[3,1],a[3,2],l); end; procedure writedata; begin writeln(aa:0:2); writeln(bb:0:2); end; function d(x1,y1,x2,y2:integer):real; begin d:=sqrt(sqr(x1-x2)+sqr(y1-y2)); end; procedure square; var p:real; begin a1:=d(a[1,1],a[1,2],a[2,1],a[2,2]); a2:=d(a[3,1],a[3,2],a[2,1],a[2,2]); a3:=d(a[1,1],a[1,2],a[3,1],a[3,2]); p:=(a1+a2+a3)/2; s:=sqrt(p*(p-a1)*(p-a2)*(p-a2)); end; begin readdata; square; if (a1*a1+a2*a2<a3*a3) or (a2*a2+a3*a3<a1*a1) or (a1*a1+a3*a3<a2*a2) then begin aa:=d(a[1,1],a[1,2],a[3,1],a[3,2]); if d(a[2,1],a[2,2],a[3,1],a[3,2])<aa then aa:=d(a[2,1],a[2,2],a[3,1],a[3,2]); end else begin h:=d(a[1,1],a[1,2],a[2,1],a[2,2]); aa:=s/(0.5*h); end; bb:=d(a[3,1],a[3,2],a[2,1],a[2,2]); if d(a[3,1],a[3,2],a[1,1],a[1,2])>bb then bb:=d(a[3,1],a[3,2],a[1,1],a[1,2]); aa:=aa-l; bb:=bb-l; writedata; end. Seems correct but gets WA#4 aa always >=0 bb always >=0 Before an input in procedure write make terms that was not aa <0 and bb <0 Maybe I'm Error,But,What mistake you think?I can not to found any mistake At a conclusion check up that aa and bb were not negative, If they will be negative appropriate him 0. Spaces and line feeds can follow each other in any order, so you need only to Read([1,1],a[1,2],a[2,1],a[2,2],a[3,1],a[3,2],l); -5 0 5 0 0 5 100 Correct answer is 0.00 0.00 | | TEST THE EXAMPLE!!! | misha | 1168. Radio Stations | 1 Aug 2008 06:01 | 2 | Is example in problem right? I think it is not!!! | | Need explanation | Sa Lang Hae | 1314. Chase in Subway | 1 Aug 2008 05:11 | 2 | if there is a route like below: 3 1 2 3 Can I go from station 3 to station 1 directly? I mean, is the route a circle? | | any hints? | Tim Green | 1314. Chase in Subway | 1 Aug 2008 05:05 | 8 | I used two SSSP algo (BFS + DFS) to solve the problem. Can it be done with only one ? how to determinate the shortest route??? Why in the test input the criminal goes to 85 and not to 10 or 75???? I too Edited by author 21.04.2004 00:39 Just 2 BFSs. Maigo Akisame (maigoakisame@yahoo.com.cn) 28 Oct 2004 08:34 First do BFS with the first node in the criminal's route. Save the result in the array d1. Do another BFS with the last node in the criminal's route, and save the result in the array d2. For any node i, if d1[i]-d2[i]=m-1, then i is an answer. The graph is always connected. I build BFS traversal tree by giving priorities to points on the route (i.e. advance them first). Children of the last route node gain privelege for the rest of traversal (if you process nodes in the order they were first visited, this condition is automatic because they will be added prior to any other nodes during last privileged propagation). After BFS tree is ready, nodes reachable from last node on the route inside that tree form the answer. Edited by author 01.08.2008 05:09 | | Ai? | Anton [SUrSU] | 1472. Martian Army | 31 Jul 2008 21:14 | 5 | Ai? Anton [SUrSU] 24 Sep 2006 16:09 What is the minimal value for Ai? Re: Ai? Tbilisi SU: Andrew Lutsenko 6 Oct 2006 20:49 "Let a commander and his subordinate have computers with numbers i and k respectively. According to the contract with the provider, the traffic between the computers i and k must be not less than Ai–Ak." Can Ai-Ak<0 ? Re: Ai? Ostap Korkuna (Lviv NU) 25 Aug 2007 15:22 You should consider both (Ai-Ak) and (Ak-Ai). Thus traffic >= max(Ai-Ak , Ak-Ai). Re: Ai? Denis Koshman 31 Jul 2008 21:14 My AC solution assumes Traffic = max(Ai-Ak, 0) | | solution | RAVEman | 1615. Tram Solitaire | 31 Jul 2008 14:55 | 10 | what is the solution for this problem? I understood that after seeing that AC solutions used 100Kb memory and about 0.001-0.015 sec. Give me some hints Ostap. :) I've spent many hours on it but still no luck :) My solution was "half guessing / half interpolation" :) I just bruteforced few answers. Guessed the denominator of the formula and then counted it's numerator assuming that it is a polynomial of degree 2. Later after the contest Vasya told me, that he produced that formula on paper theoretically. So, the strict theoretical approach is also possible. But guessing is much faster :) It's amaizing!!! Yours solution is just great (much better than Vasya's math solution), it took about 5-10mins to get AC! Thanks Ostap! Edited by author 31.03.2008 14:16 Do you need to find GCD in your solution ? Or GCD(denom, num) = 1 in your formula ? Is it so important? But - yes, i used GCD in my solution. Well, formula is simpler than expected. No factorials and big numbers. Probably I incorrectly computed answers for small n-s during contest :( Cool problem! But does anybody know the mathematical proof? Re: * Denis Koshman 31 Jul 2008 14:55 I think it can be proven by induction. Though, it most probably won't give you "sense of the things", you'll have that proof :) So far my thoughts are the following: 1. Since we remove the leftmost pair, we can lay down the whole deck at once and then perform sifting. This simplifies further thoughts a bit. 2. It might be more convenient to count amount of unsiftable final positions multiplied by number of original permutations converging to them. Unsiftable positions will be of the form ABBAABBAABB.. or AABBAABBAABB.. due to suits restriction. I think that multiplier erradicates most of (2n)! in denominator, and since history effect is 2-cards wide, the answer will be 2-polynomial. | | O,I need help,can you tell me why this wrong,thank you | sherry | 1045. Funny Game | 31 Jul 2008 14:05 | 2 | #include<stdio.h> #include<stdlib.h> #define MAX 1002 int join[MAX][MAX],cont[MAX],used[MAX],win[MAX]; int np,mark,fri; int tree(int aa) { int i,j,k,mar=0,min1=MAX,min2=MAX; used[aa]=1; if(cont[aa]==1&&aa!=fri)//!!cout为1可为终点,亦可为起点~!! { win[aa]=aa; return 0; } for(i=1;i<=np;i++) { if(join[aa][i]&&!used[i]) {
k=tree(i); if(!k&&min1>win[i]) { mar=1; min1=win[i]; } if(k&&min2>win[i]) min2=win[i]; } } if(mar) { win[aa]=min1; return 1; } else { win[aa]=min2; return 0; } } int main() { int i,j,k,mar=0; scanf("%d%d",&np,&fri); for(i=1;i<np;i++) { scanf("%d%d",&j,&k); join[j][k]=1; join[k][j]=1; cont[j]++; cont[k]++; } k=tree(fri); if(k)printf("First player wins flying to airport %d\n",win[fri]); else printf("First player loses\n"); // system("pause"); return 0; } I find where I made the mistake, I just misunderstand the porblem... | | Please somebody give mesome test I got WA3! Thank you | Husan | 1029. Ministry | 31 Jul 2008 11:14 | 1 | This is my prog #include<iostream> using namespace std; int a[102][502]={{0}},path[102][502]={{0}}; int n,m; void matr(int i) { int j; int p1[500]={0},p2[500]={0}; int pre1[500],pre2[500]; p1[0]=p2[n+1]=10000; // left to right for(j=1;j<=n;j++) if(p1[j-1]+a[i][j]>a[i][j]+a[i-1][j]){p1[j]=a[i][j]+a[i-1][j];pre1[j]=j;} else{p1[j]=p1[j-1]+a[i][j];pre1[j]=j-1;} //right to left for(j=n;j>=1;j--) if(p2[j+1]+a[i][j]>a[i][j]+a[i-1][j]){p2[j]=a[i][j]+a[i-1][j];pre2[j]=j;} else {p2[j]=p2[j+1]+a[i][j];pre2[j]=j+1;} //sravnenie for(j=1;j<=n;j++) { if(p1[j]>p2[j]){a[i][j]=p2[j];path[i][j]=pre2[j];}else{a[i][j]=p1[j];path[i][j]=pre1[j];} p1[j]=p2[j]=0; } } int main() { int i,j,min=10000,mini;
cin>>m>>n; for(i=1;i<=m;i++) { a[i][0]=a[i][n+1]=10000; for(j=1;j<=n;j++)cin>>a[i][j]; } for(i=2;i<=m;i++)matr(i); for(i=1;i<=n;i++) if(min>a[m][i]){min=a[m][i];mini=i;}; int k1=m,k2=mini,kol=1,ans[500]; if(m==1)cout<<mini;else{ ans[kol]=k2; do { kol++; ans[kol]=path[k1][k2]; if(path[k1][k2]==k2)k1--;else k2=path[k1][k2]; }while(path[k1][k2]!=0);
for(i=kol;i>=1;i--)cout<<ans[i]<<" ";} return 0; } | | Why are Russian versions of the problems not made? | Snetch | | 31 Jul 2008 06:28 | 1 | Some people might not know English. Anyway, it is a Russian website, it has to have a Russian version of anything. But so far almost one fourth of the tasks or more does not have a Russian version. All of the tasks that did not have a Russian version two years ago still do not have one. Is it really so hard for the admins to spend one day translating the tasks into Russian? Edited by author 31.07.2008 06:35 | | c++ acc problem | Oncea Beniamin | 1100. Final Standings | 31 Jul 2008 01:12 | 2 | #include <iostream> #include <stdlib.h> long long x[150001],y[150001]; using namespace std; int main(int argc, char *argv[]) { long n,f[101],i,j; for(i=0;i<=100;i++) f[i]=0; cin>>n; for(i=0;i<n;i++) {cin>>x[i]>>y[i]; f[y[i]]=1;} for(i=100;i>=0;i--) if(f[i]==1) for(j=0;j<n;j++) if(y[j]==i) cout<<x[j]<<" "<<y[j]<<endl; system("PAUSE"); return 0; } put // before system("PAUSE"); | | Does this problem require linear programming? | SPIRiT | 1449. Credit Operations 2 | 30 Jul 2008 23:00 | 4 | Funny to say, but once I've read this problem, I remembered the simplex method we were taught last year. The classic problem of simplex method is like this: find min(max)f(X)=C1*X1+C2*x2+c3*x3.. where ci - constants Also where is a system of conditions: a11*x1+..<=(>=)b1 a21*x1+..<=(>=)b2 and so on. The simplex method finds the solution very fast, but it can be a real value, not an integer. There is also a modification of SM called integer SM - it will find an integer solution. Is the problem based on this algo or not? Thanks for allowing. I think I've seen in Kormen a chapter how to model linear programming with graphs (unbelievable, isn't it?). I'll see what will happen I think you may round all BR down and all BC up to get integer solution. | | 1449- Hungarian weighted maching algorithm | svr | 1449. Credit Operations 2 | 30 Jul 2008 22:52 | 2 | Hungarian method of weighted matching! It's interesting that I solved 1449 by first version of program without any optimization. It,s rather strange because commonly challange team prepear most difficult tests with respect to time and memory. Now the problem has junior level. This is a pity, because matching frequently using on various contests. For information: Let W- weight of maximal matching in A[][] Graph. Then W- our answer. I don't consider myself a weak problem solver (even been to ACM WF twice), but it's still not obvious for me how does this problem resolve to maximal matching, and how should I convert that matching into result :) So, the problem is worth it. | | Why WA on #13? | CHN_XT | 1516. Nostalgia | 30 Jul 2008 20:38 | 2 | W....... .W...... .....W.. ..B.B... ...B.... ........ ........ ........ answer: 1 | | 0 also answer??? | Pio (Pio@mail.by) | 1437. Gasoline Station | 29 Jul 2008 20:58 | 3 | 0 also answer??? Edited by author 25.02.2006 14:04 If you ask about 0 litres - then NO. Otherwise you'll get 7 for sample input. |
|
|