Общий форум| Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения | | Clarification | Andre Linhares | 1660. Остров Невезения | 17 янв 2010 21:47 | 3 | "When no more circles can be inscribed, the distance between the first and the last inscribed circles is measured." What is the definition of the distance between two circles? As usual, min (dist(P1, P2)), where point P1 lies on the 1st circle, and point P2 lies on the 2nd circle i.e. the difference of the distance between centers of these circles and the sum of their radiuses. D=sqrt((c1.x-c2.x)^2+(c1.y-c2.y)^2) - r1 - r2. | | podvodnii kamni | Light | 1551. Турнир по сумо | 17 янв 2010 18:21 | 6 | kakoi v etoi zada4i moget bit` podvoh? u menya na 12 teste valitsa A imena rizni concurentiv? why can't you talk in english? I think it's not so hard others can take it as an OFFENCE Edited by author 29.10.2007 22:49 I can help with Russian ^ ^ 3 a a b c c b d b e a f c g b h c Right answer: 1 | | Problem is very easy, but I got wa#12... Please give me some useful tests | Crash_access_violation | 1551. Турнир по сумо | 17 янв 2010 18:21 | 4 | thanks... sorry for my bad english Names of all participants are various? or not? I assumed them various. Although, the names are not important to solve the problem; just the maximum of the number of participants from any place matters. 3 a a b c c b d b e a f c g b h c Right answer: 1 | | contacting authors | mirzauzairbaig | | 17 янв 2010 10:25 | 4 | helo! this is just a suggestion, i believe there should be an option (if they wish) for authors to display their email address to be contacted ! as it will enable and allow for more communications between authors. my address is, baiguzair@gmail[dot]com Does nobody want to stay in touch!!?? Does nobody want to stay in touch!!?? I think they may also set up a mail function inside timus... But if you want to show your email, you can set it as your motto. | | my program is correct, please tell me my error WA #4 | mirzauzairbaig | 1020. Ниточка | 17 янв 2010 10:17 | 6 | #include <iostream> #include <cmath> using namespace std; int main(){ double PI=acos(-1.0); int N; double r(0), perimeter(0); cin>>N>>r; double *pointx, *pointy; pointx = new double[N+1]; pointy = new double[N+1]; for(int a=0; a<N; a++){ cin>>pointx[a]>>pointy[a]; } pointy[N]= pointy[0]; pointx[N] = pointx[0]; cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(2); if(N==1){ perimeter=2*PI*r; cout<<perimeter; } else{ if(N==2){ perimeter=2*(pow((pow((pointx[0]-pointx[1]),2)+pow((pointy[0]-pointy[1]),2)),0.5)) + 2*PI*r; cout<<perimeter; } else{ double angle(0); for(int a=0; a<N; a++){ perimeter += pow((pow((pointx[a]-pointx[a+1]),2)+pow((pointy[a]-pointy[a+1]),2)),0.5); } double p1x, p2x, p3x, p1y, p2y, p3y, m1, m2; p1x=pointx[N-1]; p2x=pointx[0]; p3x=pointx[1]; p1y=pointy[N-1]; p2y=pointy[0]; p3y=pointy[1]; if(p3x==p2x) m1=tan(PI/2.0); if(p2x==p1x) m2=tan(PI/2.0); if(p2x!=p3x) m1=(p3y-p2y)/(p3x-p2x); if(p2x!=p1x) m2=(p1y-p2y)/(p1x-p2x); angle = 2*PI - (PI + fabs(atan(m1)-atan(m2))); for(int a=1; a<N; a++){ p1x=pointx[a-1]; p2x=pointx[a]; p3x=pointx[a+1]; p1y=pointy[a-1]; p2y=pointy[a]; p3y=pointy[a+1]; if(p3x==p2x) m1=tan(PI/2.0); if(p2x==p1x) m2=tan(PI/2.0); if(p2x!=p3x) m1=(p3y-p2y)/(p3x-p2x); if(p2x!=p1x) m2=(p1y-p2y)/(p1x-p2x); angle += ((2*PI) - (PI + fabs(atan(m1)-atan(m2)))); } perimeter += r*angle; cout<<perimeter; }} delete pointx; delete pointy; return 0;} 3 1.2 12.24 13.34 0.00 24.75 -33.36 70.12 153.41 your program is too complicated to read I will tell you about my program. I am first calculating the distance between each point and summing it (perimeter). Then I am calculating the angle; of rope wound around each nail. I am adding the angles and then finding the total length by; perimeter + radius*angle. As my angle is in radians. Now, my answer is slightly above your answer in this test case; as I can see. But, if I change my angle to be always just 2 * PI * r, then I get it right !! Now, first I can see the intuition for always setting angle to be 2*PI*r, but I cannot find any proof of why this will be always true. So, I am calculating it always for each nail. ( I think maybe, my calculation algorithm either gives a rounding error; or I am making a mistake)!! Please do reply, and tell me why? Okay, I found my mistake. And the proof;(the reason) is got to do with exterior angles of a polygon sum up to 360 degrees! :) thank you tianchb Well, I suppose perhaps float is not accurate enough... Since triangle functions in math.h are all float. Congratulations anyway. | | Suggestion | VladimirZagorodskih | | 16 янв 2010 17:56 | 2 | Why don't add a button "Random Problem" ?? Random problem from those which have not already solved. Edited by author 16.01.2010 17:56 | | WTF? | Aleksey [TeXHuK] | 1424. Маршрутка | 16 янв 2010 17:46 | 8 | WTF? Aleksey [TeXHuK] 11 ноя 2006 15:12 Please, show 9 test. Who make this problem, public your solution, please. Re: WTF? Samsonov Alex [USU] 11 ноя 2006 15:57 Probably you should try to find a bug in your code. It doesn't look like this problem have any troubles with test data. Re: WTF? Aleksey [TeXHuK] 11 ноя 2006 16:17 Without test very hardly found bugz in code :-( Re: WTF? Samsonov Alex [USU] 11 ноя 2006 19:42 But actually you have to obtain this useful skill. I have WA9 too. try test: 3 1 2 1 1 3 1 2 Re: WTF? AlexF [USTU Frogs] 18 сен 2007 10:16 I don't think that 9 test has smth special) I had a very stupid bug in my code and so had WA#9) Failed test was 10 1 7 1 1 8 2 3 3 4 4 5 5 6 6 7 7 8 IMHO Cool problem) Re: WTF? Vladimir Mihajlovski 27 май 2008 00:41 I also fall on test 9, but both of these tests work fine. What was the bug you corrected? Edited by author 27.05.2008 02:28 WA9 Programmer 16 янв 2010 17:46 | | Hint for DFS and Crash #3 !!!!! | tiancaihb | 1471. Расстояние в дереве | 16 янв 2010 12:50 | 3 | I used Tarjan Algo, based on DFS and union-find sets, but got Crash AV #3. I made a extreme data myself, like a chain from Node #0. And it really crashed with DEV-C++. I tried to enlarge the size of stack, but it seemed workless. After debugging for so long, I still can't explain why it got stuck at Node #49xxx (The program works on every "smaller data"). Do I have to make a "stack" myself? No, I came up with an idea--randomize. And with that I ACed with no difficulty. Here is the thing, maybe you picked Node #0 as the root of the tree, but why not change to a random one? I think data #3 is such a data that will make the first algo crash. Sorry for my poor English, btw. I had the same problems with this problem but increasing size of the stack helped me. Post here your e-mail and i'll send you my code. I think you understand my code because i made it the same way with you(dfs+disjoint set) tiancaihbATsinaDOTcom No, forget about it. I must have writen a wrong code The right one is #pragma comment(linker, "/STACK:16777216"). Well, that's embarrassing because you won't get CE even if it's wrong. I wrote before: #pragma comment(linker, "/STACK:64777216") Edited by author 16.01.2010 12:54 Edited by author 16.01.2010 12:55 | | WA#25: can you give me some tests? | fail | 1671. Паутина Ананси | 15 янв 2010 22:13 | 2 | I got AC when i handle multigraphs (multiple edges between pair of vertices are possible) Look my post (he located above your post in that node{ NOT MAIN NODE BUT NODE of the problem 1671}) there you can find test with multi-edges. Edited by author 15.01.2010 22:18 Edited by author 16.01.2010 13:03 | | Why WA#3. I don't know where my mistake. | Khramov Egor(9 class) | 1233. Amusing Numbers | 15 янв 2010 04:31 | 2 | Third test is the third test in the example. | | Crash on Test 1; c++; Падение на тесте 1. Что за тест? (РЕШЕНО! g++ vs. icl) | RR42 | 1001. Обратный корень | 15 янв 2010 01:57 | 2 | Странно, но со struct работает и у меня; но не на сервере. У меня libc6. #include <stdio.h> #include <math.h> struct Node // РЕШЕНИЕ: ЗДЕСЬ НУЖНО ПИСАТЬ class. Компилятор тимуса ругается почему-то. { public: Node* prev; double info; }; int main() { Node* p = NULL; Node* node; double d; while(scanf("%lf",&d)!=EOF) { node = new Node; node->info = sqrt(d); node->prev = p; p = node; } while (p != NULL) { printf("%.4lf\n", p->info); p = p->prev; } return 0; } Edited by author 31.12.2009 03:44 Выводить надо в обратном порядке | | To Admins | Prabhjot Singh | 1119. Метро | 15 янв 2010 01:13 | 1 | I have got AC for this problem but my solution is quite inefficient http://acm.timus.ru/status.aspx?space=1&num=1119&author=82952 It takes me 0.156 seconds to compute the answer, but there are many ppl who got solution in 0.015 secs.If possible please email me one of the efficient solution (C++ one).my email address is pjas002@aucklanduni.ac.nz Thanks | | test #12 | Zrutor | 1024. Перестановки | 14 янв 2010 20:10 | 1 | Would anyone happen to know what test #12 is, or otherwise suggest something similar? Because I keep getting Time limit exceeded on it. Thanks in advance. | | About timus Vkontakte.ru =) | Ras Misha [t4ce] | | 14 янв 2010 18:22 | 1 | | | Please Help me! I've got WA#4! | {AESC USU} Dembel | 1301. Кубик в лабиринте | 13 янв 2010 22:48 | 5 | Please give me some test or hint. Give me your mail, I'll try to help you) My mail: <deleted> Edited by author 29.11.2007 19:39 Mistake because of wrong processing obstacles | | Wrong answer why | zarrafa | 1020. Ниточка | 13 янв 2010 10:28 | 2 | #include <stdio.h> #include <math.h> int main(){ freopen("b.in","r",stdin); freopen("b.out","w",stdout); double x[102],y[102]; double d1,d2; int i,star=0,k,m,n,j; double s,r,pi=2*acos(0); scanf("%d",&k); for(m=0;m<k;m++){ s=0; scanf("%d %Lf",&n,&r); for(i=0;i<n;i++) scanf("%Lf %Lf \n",&x[i],&y[i]); for(j=0;j<n-1;j++){ d1=abs(x[j]-x[j+1]); d2=abs(y[j]-y[j+1]); s=s+sqrt(d1*d1 + d2*d2); } d1=abs(x[0]-x[n-1]); d2=abs(y[0]-y[n-1]); s=s+sqrt(d1*d1 + d2*d2); s=s+(n*pi*r)/2; if(star==0) star=1; else printf("\n"); printf("%.2Lf",s); } return 0; } #include <iostream> #include <cmath> using namespace std; int main(){ double PI=acos(-1.0); int N; double r(0), perimeter(0); cin>>N>>r; double *pointx, *pointy; pointx = new double[N+1]; pointy = new double[N+1]; for(int a=0; a<N; a++){ cin>>pointx[a]>>pointy[a]; } pointy[N]= pointx[0]; pointx[N] = pointy[0]; cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(2); if(N==1){ perimeter=2*PI*r; cout<<perimeter;
} else{ if(N==2){ perimeter=2*(pow((pow((pointx[0]-pointx[1]),2)+pow((pointy[0]-pointy[1]),2)),0.5)) + 2*PI*r; cout<<perimeter;
} else{ double angle(0); for(int a=0; a<N; a++){ perimeter += pow((pow((pointx[a]-pointx[a+1]),2)+pow((pointy[a]-pointy[a+1]),2)),0.5); }
double p1x, p2x, p3x, p1y, p2y, p3y, m1, m2;
p1x=pointx[N-1]; p2x=pointx[0]; p3x=pointx[1]; p1y=pointy[N-1]; p2y=pointy[0]; p3y=pointy[1]; if(p3x==p2x) m1=tan(PI/2.0); if(p2x==p1x) m2=tan(PI/2.0); if(p2x!=p3x) m1=(p3y-p2y)/(p3x-p2x); if(p2x!=p1x) m2=(p1y-p2y)/(p1x-p2x); angle = 2*PI - (PI + fabs(atan(m1)-atan(m2))); for(int a=1; a<N; a++){ p1x=pointx[a-1]; p2x=pointx[a]; p3x=pointx[a+1]; p1y=pointy[a-1]; p2y=pointy[a]; p3y=pointy[a+1]; if(p3x==p2x) m1=tan(PI/2.0); if(p2x==p1x) m2=tan(PI/2.0); if(p2x!=p3x) m1=(p3y-p2y)/(p3x-p2x); if(p2x!=p1x) m2=(p1y-p2y)/(p1x-p2x);
angle += ((2*PI) - (PI + fabs(atan(m1)-atan(m2)))); }
perimeter += r*angle; cout<<perimeter; }} delete pointx; delete pointy; return 0;}
// even me wrong answer Edited by author 13.01.2010 20:27 Edited by author 13.01.2010 20:27 | | why wa#10 (c#) | Ras Misha [t4ce] | 1038. Проверка орфографии | 12 янв 2010 15:50 | 2 | using System; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { string razd=":;, -"; string kp=".!?"; string dig = "0123456789"; string[] input = Console.In.ReadLine().Split( new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries); int cnt = 0; int ns = 0; int nb = 0; for (int i = 0; i < input.Length; i++) { string s = input[i]; for (int j = 0; j < s.Length; j++) { if ((s[j] >= 'A' && s[j] <= 'Z') || (s[j]>='a' && s[j]<='z') || dig.IndexOf(s[j])>=0) { nb++; if (ns == 0) ns++; if (nb == 1 && ns == 1 && (s[j] >= 'a' && s[j] <= 'z')) cnt++; if ((s[j] >= 'A' && s[j] <= 'Z') && nb > 1) cnt++; } if (razd.IndexOf(s[j]) >= 0) { nb=0; if (ns > 0) ns++; } if (kp.IndexOf(s[j])>=0) { ns = 0; nb = 0; } } nb = 0; } Console.WriteLine(cnt.ToString()); Console.ReadKey(); } } } i got wa in #10 too try this Asf,.,a the ans is 1 | | Test 12 | bsu.mmf.team | 1694. Слова-убийцы | 11 янв 2010 23:16 | 2 | Test 12 bsu.mmf.team 27 ноя 2009 06:18 What the answer to test: m k n 12 3 2 18 I got 53 and WA | | WA 4# Please help | Marck | 1095. Никифор 3 | 10 янв 2010 19:32 | 2 | I really don't like to do it, but i just can't find what is wrong in my code... In my pc it works pretty fine.. but, i got WA 4#... my bugged code: ========================================================== #include <iostream> using namespace std; void reordena(int *numeros[],int difzero,int num) { int rdn1,rdn2,aux; rdn1 = rand() % difzero; rdn2 = rand() % difzero; aux = numeros[num][rdn1]; numeros[num][rdn1] = numeros[num][rdn2]; numeros[num][rdn2] = aux; } void permuta(int *numeros[],int num,int tam) { int cont,cont2,aux,difzero=0,resp=0; int mult; long int contador=0; for(cont=0;cont<tam-1;cont++) { for(cont2=0;cont2<tam-1;cont2++) { if(numeros[num][cont2]==0) { aux = numeros[num][cont2]; numeros[num][cont2] = numeros[num][cont2+1]; numeros[num][cont2+1] = aux; } } } for(cont=0;cont<tam;cont++) { if(numeros[num][cont]!=0) difzero++; } mult=1; for(cont=difzero-1;cont>=0;cont--) { aux=(numeros[num][cont]*mult); resp+=aux; mult*=10; } while(resp%7!=0) { reordena(numeros,difzero,num); mult=1; resp=0; for(cont=difzero-1;cont>=0;cont--) { aux=(numeros[num][cont]*mult); resp+=aux; mult*=10; } contador++; if(contador>=1000000) { numeros[num][0]=0; resp=0; } } } int main() { int N,cont,**numeros,*tam; char aux[200]; cin >> N; if(N<0) exit(0); if(N>10000) exit(0); tam = new int[N]; numeros = new int*[N]; for(cont=0;cont<N;cont++) { numeros[cont] = new int[20]; } for(cont=0;cont<N;cont++) { cin >> aux; tam[cont] = strlen(aux); if(tam[cont]>20) { exit(0); } for(int cont2=0;cont2<tam[cont];cont2++) { numeros[cont][cont2]=aux[cont2]-'0'; } permuta(numeros,cont,tam[cont]); } system("cls"); for(cont=0;cont<N;cont++) { for(int cont2=0;cont2<tam[cont];cont2++) { if(numeros[cont][0]==0) { if(cont2==0) cout << "0"; } else if(numeros[cont][cont2]!=0) cout << numeros[cont][cont2]; } if(cont!=N-1) cout << endl; } delete [] numeros; delete [] tam; return 0; } ======================================================== please, help if you can =/ May be late=) but if input data contain 0 all zeroes must be output for example input: 1 12300134 example output: 13124300 | | what is the problem with the 2 test? | 2angels | 1041. Никифор | 10 янв 2010 13:50 | 1 | May be anybody knows, what is specific of the second test? All my examples work correctly, but the second test...... }:-/ |
|
|