| Show all threads Hide all threads Show all messages Hide all messages |
| Can we get the test cases on which you judge our solution ? | Nitiraj Singh Rathore | | 31 Mar 2009 18:50 | 1 |
Hi, My answer to the problem 1002 was having "time limit exceeded" problem and sent for test#5. Can I get the test cases on which you are judging our answers so that I can check if my program is working fine with these cases or what error is coming ??? |
| if yor have WA #9 float poin error, i'am ascape it after | Валентин | 1075. Thread in a Space | 31 Mar 2009 18:43 | 1 |
ac := sqrt(sqr(xa-xc) + sqr(ya-yc) + sqr(za-zc)); bc := sqrt(sqr(xb-xc) + sqr(yb-yc) + sqr(zb-zc)); ab := sqrt(sqr(xa-xb) + sqr(ya-yb) + sqr(za-zb)); //without this i have error if (ac = 0) or (bc = 0) or (ab = 0) then begin writeln(0); halt; end; //end |
| Could somebody tell me what's the test 27? | yuyan | 1508. Japanese Puzzle | 31 Mar 2009 18:33 | 1 |
I got WA on it about 20 times.I'm crazy now! Please help me. Thank you! |
| Make the function faster | Mohit Kanwal | 1002. Phone Numbers | 31 Mar 2009 15:24 | 4 |
Hi All, I am a beginner to this site and tried to solve the problem . I am using DP but time limit is exceeded on test # 5 . what algorithm shud I use or wat improvements can I do to my code. /////////////////////////////////////////////////////////// #include <iostream> #include <algorithm> #include <string> #include <map> #include <fstream> #include <vector> using namespace std; map <char, char> guide; void initialise() { guide['i'] = '1';guide['j'] = '1';guide['a'] = '2';guide['b'] = '2';guide['c'] = '2';guide['d'] = '3'; guide['e'] = '3';guide['f'] = '3';guide['g'] = '4'; guide['h'] = '4';guide['k'] = '5';guide['l'] = '5';guide['m'] = '6';guide['n'] = '6';guide['p'] = '7'; guide['r'] = '7';guide['s'] = '7';guide['t'] = '8';guide['u'] = '8';guide['v'] = '8';guide['w'] = '9'; guide['x'] = '9';guide['y'] = '9';guide['o'] = '0';guide['q'] = '0';guide['z'] = '0'; } string getcode(string& str) { string::iterator it; string s; for(it = str.begin();it!=str.end();it++) { s.push_back(guide[(*it)]); } return s; } /*void solve(map <string,vector<string> > m1,string& call) { string ret; typedef string::iterator iter; iter it; vector < <string> :: iterator > pos; typedef map <string,vector <string> > :: iterator t; for(it=call.begin();it!=call.end();it++) { for(iter i = it;i!=call.end();++i) { t mt = m1.find(string(it,i)); if(mt != m1.end()) {//we found the 1st word //must note the position and store in vector // keep erasing the last one if it is not found pos.push_back(i);
ret.append(mt->second[0]); it = i; it++; //need to find more } } } if(ret.length()!=call.length()) cout<<"No Solution"; else cout<<ret; }*/ string select(vector < vector<string::iterator> > &book,map <string , vector <string> > &m1,string &str) { string ret; int best = book[0].size(); int pos = 0; for(int i=1;i<book.size();i++) { if(book[i].size()<best) { pos = i; best = book[i].size(); } } for(int j = 0;j<best-1;j++) { ret.append(m1[string(book[pos][j],book[pos][j+1])][0]); ret.append(" "); } return ret; } string solve(map <string , vector <string> > &m1,string &str) { int best = 9000000000; bool no_soln = true; bool found = false; typedef string :: iterator iter; typedef map <string, vector <string> >::iterator it; vector <string :: iterator> sp; vector < vector<string::iterator> > db; sp.push_back(str.begin()); int c = 0; iter j = sp[c]; while(!(found) && c!=-1) { do { if (c>best || c==best-1) break; j++; it h = m1.find(string(sp[c],j)); if (h!=m1.end()) { //we found one word so push it //cout<<h->second[0]<<" "; sp.push_back(j); c++; } }while(j!=str.end()); //cout<<c<<" "; //check whether found or not if(sp[c] == str.end()) { if (best>c) best = c; cout<<best<<" "; no_soln = false; db.push_back(sp); sp.pop_back();c--; j = sp[c]; sp.pop_back();c--; } else {j = sp[c];sp.pop_back();c--;} } if (!(no_soln)) return select(db,m1,str); else return "No solution."; } void printing(map <string, vector <string> > &m1) { map<string,vector <string> > :: iterator it; it = m1.begin(); while(it != m1.end()) { cout<<(*it).first<<" "<<it->second[0]<<"\n"; it++; } } vector <string> readinput(istream &in) { vector <string> ret; string call; getline(in,call); while((call.compare("-1"))!=0) { map <string , vector<string> > dict; int words=0; //getline(in,call); in>>words; in.ignore(255,'\n'); string line; while(words>0) { getline(in,line); dict[getcode(line)].push_back(line); words--; } //printing(dict); ret.push_back(solve(dict,call)); getline(in,call); } return ret; } int main() { ifstream infile; infile.open("DATA.in"); ofstream outfile; outfile.open("DATA.out"); initialise(); vector <string> ans; ans = readinput(infile); for(int i=0;i<ans.size();i++) outfile<<ans[i]<<endl; /*string m; getline(cin,m); cout<<getcode(m); */ //getch(); infile.close(); outfile.close(); return 0; } Cud u give me a hint !!! Thanks 1. When you write: something::iterator iter; for(iter = container.begin(); iter != container.end(); ++iter) ... container.end() is called each iteration. something::iterator iter, iter_end; for(iter = container.begin(), iter_end = container.end(); iter != iter_end; ++iter) ... is better. 2. When you write: while(...) { int i; ... } i is allocated from stack each iteration. int i; while(...) {...} is better. 3. vector<smth>::push_back() is a very slow operation. It allocates a new piece of memory, copies copies all previous values and a new one to it, and frees the old piece of memory. Performance of push_back() is better in deque and list. 4. printf() and scanf() are better than cin, cout, ifstream, ofstream, fstream in performance. Edited by author 31.03.2009 15:38 |
| Weak tests | Fyodor Menshikov | 1306. Sequence Median | 31 Mar 2009 15:10 | 4 |
I know AC solution that fails the following test: 2 3000000000 3000000000 The problem test set awhile does not contain tests where median computed as average of two elements and sum of these elements is greater than 2^32 - 1. I know AC solution that fails the following test: 2 3000000000 3000000000 use a / 2.0 + b / 2.0 instead of (a + b) / 2.0 http://acm.timus.ru/news.aspx 3.02.2009. Problem 1306 Sequence Median. Statement updated Now each element of the sequence is a positive integer not greater than 2^31−1 inclusive (old limitation was 2^32−1). Edited by author 31.03.2009 15:10 |
| WA on test7 | Erjin Zhou | 1430. Crime and Punishment | 31 Mar 2009 13:57 | 1 |
I need help... what is the test 7? |
| Tip: WA on Test #4 | Stefan Marinov | 1174. Weird Permutations | 31 Mar 2009 01:39 | 1 |
Check whether the biggest possible answer does fit into the data type used. Edited by author 01.04.2009 21:58 |
| what is wrong? | safeperson | 1001. Reverse Root | 30 Mar 2009 23:42 | 3 |
#include<stdio.h> #include<math.h> int main(void) { double a[256*1024/sizeof(double)];
int i=0;
while(i < 256*1024/sizeof(double)) { scanf("%lf",&a[i]);
i++; } for(--i;i >=0 ; i--) printf("%.4lf\n",sqrt(a[i]));
return 0;
} The number of input numbers can be less than 256*1024. Use the fact that when scanf cannot read next double it returns 0 (it returns the number of successfully read parameters), and break your while then. just use <stack> from stl |
| WA 3 | kal1sha | 1683. Fridge | 30 Mar 2009 22:54 | 2 |
WA 3 kal1sha 5 Mar 2009 16:18 Give me tests... 24 5 11 6 3 2 1 48 6 23 12 6 3 2 1 correct? My AC Solution: 24 5 12 6 3 1 1 ---- 48 6 24 12 6 3 1 1 ---- 1024 10 512 256 128 64 32 16 8 4 2 1 Good luck. Edited by author 30.03.2009 22:54 |
| If possible more then one solution, printf anyone? | spiker | 1683. Fridge | 30 Mar 2009 22:52 | 3 |
I`m interesed too, is it correct answer for this example: ***input*** 12 ***output*** 4 6 3 1 1 as in exanple answer is a little different, it is 4 5 3 2 1 |
| WA#1!!!!!!!!!!!!!WHY??????????? | Artem | 1403. Courier | 30 Mar 2009 14:58 | 1 |
I have got wrong answer on first test!! my program out right test on my computer! |
| Java solution exists! | Fyodor Menshikov | 1220. Stacks | 30 Mar 2009 08:49 | 4 |
I've solved this problem in Java! http://acm.timus.ru/status.aspx?space=1&num=1220&author=23793 FAQ ( http://acm.timus.ru/help.aspx?topic=java&locale=en) says "Here is the list of the problems which are not guaranteed to be solvable in Java: 1220, 1275, 1306." Now 1220 may be removed from this list. Russian version of the FAQ slightly more close to the truth. It says that problems except 1220, 1275 and 1306 may be solved in Java _without_significant_difficulties_. And this statement is true. 1220 _may_ be solved in Java, but with much more difficulty than in Pascal or C++. how to C# ? Your solution 2525637 uses only 300 kb of memory. Probably it does nothing, but 750-300 kb is enough to get AC using right techniques. The most important is to not create objects. So no strings, only reusable arrays of characters. And probably you are to implement reading and writing classes over byte IO that do not use object creation. Your solution 2525637 uses only 300 kb of memory. Probably it does nothing. ------------------------ Yes, it's only: static void Main(){} but it uses 365KB memory. The most important is to not create objects. So no strings, only reusable arrays of characters. And probably you are to implement reading and writing classes over byte IO that do not use object creation. ------------------- i shall try. thank you very much. |
| And what about solving this problem without any arrays? | Oleg Strekalovsky [Vologda SPU] | 1048. Superlong Sums | 30 Mar 2009 00:06 | 6 |
I solved this problem on Java. Memory < 1 М .Time was about 0.8 c. Without any arays!!! Are your can? =). Thanks to Fyodor Menshikov. He was rigth about limitation. Using recursive procedure like topological sorting. Recursion implicitly uses array (stack), so used memory will be the same. Edited by author 13.01.2009 23:26 And how? Think. Look at memory compsumption of first solutions of the problem. if(A+B > 9) ..... Console.Write(last+1); if(A+B == 9) count++; ...... if(A+B < 9) Console.Write(last); but it's slow,so it's not a good way |
| The answer for n=3000? | AmBush | 1222. Chernobyl’ Eagles | 29 Mar 2009 19:32 | 8 |
What is the answer for n=3000? According to my problem it is: 1112410638837951982681559213420228436655660132143101893639583499479104 8307860224498112075664780555124758923322998295448875554498944133575085 7206969739792707314008867553774340959765426840307082886757146900689409 1769558402678831747586833656908719011631685677289799215417532225045801 3194444896132535792828846054226294650004927200184834052327444607699483 6595280893152817992146653301160115779064762003728308491537220749832979 2557104621996394714041315150395706599135856376433569557036792447902521 76364500701 but i've got WA HELP! n=3000 6230944380615661730540866744905062220607354471963766287778397756065940 6962697903814082629320941801101660304581383981489487361062625347661816 5706321659264965023017203487210780255823880970691747085650866739360077 645709393425508719830393155473510779779930751 But I got wa too. 1322070819480806636890455259752144365965422032752148167664920368226828 5973467048995407783138506080619639097776968725823559509545821006189118 6534272525795367402762022519832080387801477422896484127439040011758861 8041128947815623094438061566173054086674490506178125480344405547054397 0388958174653682549161362208302685637785822902284163983078878969185564 0408489893760937324217184635993869 13220708194808066368904552597521443659654220327521481676649203682268285973467048 99540778313850608061963909777696872582355950954582100618911865342725257953674027 62022519832080387801477422896484127439040011758861804112894781562309443806156617 30540866744905061781254803444055470543970388958174653682549161362208302685637785 82290228416398307887896918556404084898937609373242171846359938695516765018940588 109060426089671438864102814350385648747165832010614366132173102768902855220001 78269792221766377248792586107312578551454955298456387837931004855964813172193821243390064215949238600077681954053753825948909941306968357700343451652009989159020094600778289423859975436358546313727455317042603649908448160723189846384364576128985442328158891806918309846544996297697505373844135967311576127112637752359444869773878802929985672496258464403635036929317966161945895754817512140406205791563756008285751669647079656658308372789688485874728678798223164136163414900736 When n=3000 my AC program print: 1322070819480806636890455259752144365965422032752148167664920368226828597346704899540778313850608061963909777696872582355950954582100618911865342725257953674027620225198320803878014774228964841274390400117588618041128947815623094438061566173054086674490506178125480344405547054397038895817465368254916136220830268563778582290228416398307887896918556404084898937609373242171846359938695516765018940588109060426089671438864102814350385648747165832010614366132173102768902855220001 Because correct is: 1322070819480806636890455259752144365965422032752148167664920368226828597346704899540778313850608061963909777696872582355950954582100618911865342725257953674027620225198320803878014774228964841274390400117588618041128947815623094438061566173054086674490506178125480344405547054397038895817465368254916136220830268563778582290228416398307887896918556404084898937609373242171846359938695516765018940588109060426089671438864102814350385648747165832010614366132173102768902855220001 |
| Format Problem!!! | Sergio Marquez | 1222. Chernobyl’ Eagles | 29 Mar 2009 19:24 | 7 |
How Can I show the longest value with all digits. Now I show for n=3000 1.32207e+477 I use long double. somebody can help me???? Use array friend, write your own multiply function. Timus array max size = 64 K (or i may wrong) which means you can create char array[64000] store up to 64K digit Edited by author 16.04.2007 20:37 Edited by author 16.04.2007 20:56 size of array is not limited. if you need you can create array of any size. you must to implemet your own multiplication. algorithm is the same as you do it in your exercise book if in pascal you can use extended |
| My method | wu hao | 1222. Chernobyl’ Eagles | 29 Mar 2009 19:23 | 2 |
F[i] = Max[F[i-j]*j} (0<i<=20) 1 (i=0) F[i-3]*3 (i>20) In this way,you can solve the problem in O(n^2). Edited by author 28.01.2009 03:58 |
| Need help!!! | Lebedev_Nicolay[Ivanovo SPU] | 1220. Stacks | 29 Mar 2009 15:50 | 2 |
I had MLE #1 with 2 arrays: (C ++) int a[ 100000 ], short b[ 100000 ]; How to use 1 array instead of two??? int a[ 100000 ], short b[ 1000 ]; |
| Very strange tests | Fyodor Menshikov | 1317. Hail | 29 Mar 2009 05:04 | 3 |
I know solution that gets AC with parameter EPS from 1e-0 to 1e-15 (1e+1 and 1e-16 get WA). It is _very_ strange that tests allow such inaccuracy. It depends on the way use solve the problem. If you do all calculations in integers, any EPS from 1e-0 to 1e-15 will give right answer =) If you do all calculations in integers, any EPS from 1e-0 to 1e-15 will give right answer =) How can you do all calculations in integers if there are a lot of real numbers in input and no limits on number of digits after decimal point? |
| MLE #1 | Lebedev_Nicolay[Ivanovo SPU] | 1220. Stacks | 28 Mar 2009 23:31 | 8 |
MLE #1 Lebedev_Nicolay[Ivanovo SPU] 1 Mar 2009 16:10 I use : int a[ 100000 ]; short num[ 100000 ]; And I have MLE #1!!! 100000 * 4 + 100000 * 2 = 600000 bytes + plus memory for your programm. Memory limit can be 750000 bytes instead of 750 Kb. Re: MLE #1 Lebedev_Nicolay[Ivanovo SPU] 1 Mar 2009 21:37 Re: MLE #1 Vedernikoff Sergey (HSE: EconomicsForever!) 1 Mar 2009 21:44 You use too much memory. Try to fit into one array int[100000]... Re: MLE #1 Lebedev_Nicolay[Ivanovo SPU] 1 Mar 2009 23:12 Can you prompt me? I can't think up how to do it. Re: MLE #1 Vedernikoff Sergey (HSE: EconomicsForever!) 2 Mar 2009 03:15 For example, look at corresponding section in D. Knuth's book (something about several stacks in one memory segment) Re: MLE #1 Lebedev_Nicolay[Ivanovo SPU] 4 Mar 2009 23:18 I can't find it!? Can you tell me any idea??? Re: MLE #1 Amirbekov Artem[Ivanovo SPU] 28 Mar 2009 23:31 Just use the "realloc()" function ;-) |
| N Dijkstras rulezz =) | Глащенко Никита | 1004. Sightseeing Trip | 28 Mar 2009 22:39 | 1 |
|