Common BoardI receive compilation error but in Borland C++ all ok. What is problem? #include<iostream.h> #include<stdlib.h> #include<string.h> void main() { unsigned long N, K, i, position; char * mas[30000]; char * mas1[30000]; char * mas2[30000]; char * mas3[10000]; cin>>N; cin>>K; for( i = 1 ; i <= N; i++) { if(i < 30000) { ultoa(i, mas[i - 1], 10/* size(i)*/); } else if (i < 60000) { ultoa(i, mas1[i - 30001] , 10/* size(i)*/); } else if (i < 90000) { ultoa(i, mas2[i - 60001] , 10/*size(i)*/); } else if (i < 100000) { ultoa(i, mas3[i - 90001] , 10/*size(i)*/); } } i = 0; position = 0; int step = 0; while( i < N) { while(step < K) { if(position >= N) position = position - N; if(position < 30000) { if(strcmp(mas[position], "0") != 0) step ++; } else if(position < 60000) { if(strcmp(mas[position - 30000], "0") != 0) step ++; } else if(position < 90000) { if(strcmp(mas[position - 60000], "0") != 0) step ++; } else if(position < 100000) { if(strcmp(mas[position - 90000], "0") != 0) step ++; } position++; } step = 0; position --; if(position < 30000) { cout<<mas[position]; mas[position] = "0"; } else if(position < 60000) { cout<<mas1[position]; mas1[position] = "0"; } else if(position < 90000) { cout<<mas2[position]; mas2[position] = "0"; } else if(position < 100000) { cout<<mas3[position]; mas3[position] = "0"; } cout<<" "; i++; position ++; } } #include <iostream> #include <stdio.h> using namespace std; int main() { int i,n,a; double o=0; cin>>n; for(i=1;i<=n;i++) { cin>>a; o+=a; } o/=n; fprintf(stdout,"%.6lf ",o); cout<<endl; return 0; } Edited by author 07.04.2009 21:17 Edited by author 08.04.2009 12:58 In English version of the site, the page offering to enter JUDGE_ID and password when viewing source has a button with Russian caption - "Продолжить" Simple questiong :D I just can't get it, how should we connect carriages? If we have "AA" "BA" "AB" what can we connect "AABA" or "AAAB"??? #include <iostream> using namespace std; int main() { int n,a[1024],br=1,i; cin>>n; cin>>a[1]; if(n==1) { cout<<"1 "<<a[1]; } for(i=2;i<=n;i++) { cin>>a[i]; if(a[i]==a[i-1]) { br++; } if(a[i]!=a[i-1]) { cout<<br<<" "<<a[i-1]<<" "; br=1; } if(i==n) { cout<<br<<" "<<a[i]; } } cout<<endl; return 0; } Edited by author 07.04.2009 21:12 program Ural1078; var ok:array[1..500,1..500]of boolean; x,y,ans:array[1..500]of longint; a,b,n,max:longint; function dfs(o,l:longint):boolean; var i:longint; u:boolean; begin u:=false; for i:=1 to n do if ok[o,i] then u:=u or dfs(i,l+1); if max<l then begin max:=l; u:=true; end; if u then ans[l]:=o; exit(u); end; begin readln(n); fillchar(ok,sizeof(ok),false); for a:=1 to n do readln(x[a],y[a]); for a:=1 to n do for b:=1 to n do if (x[a]<=x[b])and(y[b]<y[a]) then ok[a,b]:=true; max:=0; for a:=1 to n do if dfs(a,1) then ans[1]:=a; writeln(max); for a:=max downto 1 do write(ans[a],' '); end. What is wrong??? I use greedy to solve this problem. First,I scanned all the boxes.If it had N new different coins that Tom wanted.The purchase will added about N*100 Then,I think Tom would buy this box.And it costs him 100 yen. At last.If the purchase>0 ,then I would buy some boxes that Tom did not have been bought. I was WA on #1 Am I wrong? At last,I'm sorry for my poor English. Thanks a lot. I spent about 20 attempts on this problem (yea, it's funny). It's all because i got wa12 instead of crash 12 when my recursive dfs led to stack overflow. P.S. Test 12: n=50000,m=49999, and [probably] graph is line. Edited by author 06.04.2009 19:04 Who can explane me that question,thank you there're two piles where you must put stones with condition that differences in weight between piles should be the minimal. Edited by author 06.04.2009 14:10 Please try this test.This test helps me a lot. 20 3 2 1 5 1 4 8 12 16 The answer is 0. Help! I get Wrong Answer on test 8... If someone knows 8th test please post it...thanks I get wrong answer on test 8 too. # include <iostream.h> # include <string.h> int main () { char a[2002][202]; char b[10000][1000]; char c[10000][1000]; char d[10000][1000]; char e[10000][1000]; int n,i,j=0,k=0,m=0,h=0; cin>>n; for (i=0;i<2*n;i++) cin.getline (a[i],2002,'\n'); for (i=0;i<2*n;i=i+2) { if (a[i+1][0]-'0'=='S'-'0') { strcpy(b[j],a[i]); j++; } else if (a[i+1][0]-'0'=='H'-'0') { strcpy(c[k],a[i]); k++; } else if (a[i+1][0]-'0'=='G'-'0') { strcpy(d[m],a[i]); m++; } else if (a[i+1][0]-'0'=='R'-'0') { strcpy(e[h],a[i]); h++; } } cout<<"Slytherin:"<<endl;; for (i=1;i<=j;i++) cout<<b[i]<<endl; cout<<'\n'<<"Hufflepuff:"<<endl; for (i=1;i<=k;i++) cout<<c[i]<<endl; cout<<'\n'<<"Gryffindor:"<<endl; for (i=1;i<=m;i++) cout<<d[i]<<endl; cout<<'\n'<<"Ravenclaw:"<<endl; for (i=1;i<=h;i++) cout<<e[i]<<endl; return 0; } Tell mi what to do,please, and sorry for my English. your sorce is wronge it is crashing because of char a[2002][202]; char b[10000][1000]; char c[10000][1000]; char d[10000][1000]; char e[10000][1000]; you got to change to: char a[103][1002]; char b[102][1002]; char c[102][1002]; char d[102][1002]; char e[102][1002]; but on the first test the program output : Hufflepuff: Gryffindor: Ravenclaw: the wright answer is : Slytherin: Zlobeus Zlei Um Bridge Hufflepuff: Mac Go Nagolo Gryffindor: Ivan Ivanov Garry Potnyj Herr Mionag-Ranger Ravenclaw: Tatiana Henrihovna Grotter I spend 3 hours searching to find the bug, but i found nothing, pls help me solve it... i had the same problem, but after realising that i might have made a mistake somewhere, i tried test case someone else already posted: 5 0 0 0 2 1 1 2 0 2 2 so, when i "fixed" my program, now i have WA#4 instead of WA#7 :P Rejudging of the contest after the contest is a VERY BAD THING! I am SURE that a lot of people who found solution for problem F can find error and write own sqrt function for int64. BUT if you have not tests that fails this on the contest you CAN NOT do rejudge after IT. YOU CAN CHANGE THE DESCRIPTION OF THE PROBLEM TO SATISFY THE DATA SET BUT YOU CAN NOT CHANGE DATA SET! In this case results of the contest is not objective at all. Edited by author 05.04.2009 01:58 We apologize to all participants of the online contest whose submit during the contest lost AC verdict. Adding new tests to the problems of Timus Online Judge is a usual rule of this site, but we agree that the rejudge of the contest is not fair thing. I'll try to explain why we he had to rejudge this problem. Because of technical error only 3 first tests from this problem's test set were installed to the Timus Online Judge. Unfortunately we have found this error only after the contest was finished. Now this problem has all tests that were prepared for the contest by its author. No new tests were added as a result of investigation of AC solutions of the contest. Я построил дерево, программа работает правильно, но требует около 90МБ памяти. Как можно сократить количество используемой на дерево памяти? Попробуй взять другой алгоритм. Префиксные массивы проходят по времени. there exist simple O(N^2) DP (N^2 memory) but on the contest i have solve it in O(N^2) using hash (O(N) memory) How to DP in this problem? Что за дерево Вы строите? Я строил суффиксное дерево, представляя ребра как два целых числа - начало и длины. Всего я поставил ограничение на массив вершин, используемых деревом, 40000 вершин (что в память уложится по-любому - в вершине хранится начало текста, длина текста, и 26 указателей на потомков). Совет: дерево должно быть компактным, то есть не отводить по вершине на символ, а только на разветвления, в этом случае дерево требует O(m) вершин, где m - длина текста. Проходит наивный алгоритм построения за O(N^2). sos!! thanks > I think it's 85096170 > > I think it's 85096170 i've just got accpted thankz I try to solve it for O(n * log(n) * log(n)). I don't understand why I can't passed it? Please help me. I can send my code. Edited by author 11.03.2007 15:15 you can solve this problem using one DFS. think about it Thank you very much. It's problem very easy... And I'm very stupid. Now I have AC. I've solved it with LCA Does more simple way exists? I've solved it with LCA Does more simple way exists? Yes of course. run DFS once and for each vertex remember when you came to this vertex and when you returned there. and then it's very easy to find answer:) Thank you for really good idea It's much more simple to implement then LCA:) 10 2 5 1 1 6 1 4 4 5 5 8 7 9 Answer: 5 1 2 3 4 5 |
|