Общий форум12341321 12344321 12991321 12999921 12341991 12344321 12343991 12344321 12344991 12355321 1234554991 1234664321 1234559991 1234664321 1134559921 1134664311 1134998821 1135005311 8999999999 9000000009 89999 90009 1250025 1250521 1999 2002 100003 101101 11111 11111 1000003 1001001 1999992 2000002 1009002 1010101 18 22 36313404080 36313431363 3373687313428241827948801150507677526 3373687313428241828281428243137863733 669262074855963079771197586206281259112 669262074855963079777970369558470262966 242167700017836474388100 242167700018810007761242 16252383 16255261 469342775745586144105609869 469342775745595547577243964 37461293193018561603953493340 37461293193018581039139216473 9194184285169534216966507128749 9194184285169534359615824814919 21 22 1330454685235862 1330454774540331 78336742687917227491028 78336742687978624763387 47923802054017335212073765802860114 47923802054017335253371045020832974 505752 506605 940 949 428540910018912794058956977 428540910018919810019045824 9770330728908946347636591906356869449214 9770330728908946347667436498098270330779 7068416097840258049887921681085 7068416097840258520487906148607 517805724457730620 517805725527508715 506833497 506838605 5820 5885 484243646784563247619038458645194136 484243646784563247742365487646342484 91413688117232096060 91413688122188631419 771886477139587251334596 771886477139931774688177 8304292305552149553379655920949280409378 8304292305552149553443559412555032924038 9628134090110628 9628134114318269 2445193927845273449357413443 2445193927845335487293915442 519 525 6885428526826048829 6885428527258245886 72924386042452563577194755578 72924386042452625424068342927 123012 123321 123131 123321 36408 36463 123 131 I get AC using priority_queue<unsigned int> At first I push n/2+1 numbers then I read next number,push it to queue,pop biggest element until I have elements If n odd I use 1 top elem for answer else I use 2 top elements for answer such way: if (top1+top2) mod 2=0 I output top1/2+top2/2+top1 mod 2 and then print ".0" else I output top1/2+top2/2 and then print ".5" I hope it'll help somebody. P.S thank to authors of this problem.I like this problem very much!
Edited by author 07.02.2008 01:49 CHIDEMYAN SERGEY, thanks a lot! You helped me very much. Finally, I passed it! Edited by author 21.03.2012 15:27 It's getting MLE7 . I did as you said! Edited by author 24.01.2018 22:56 Edited by author 24.01.2018 22:56 new compilers "eat" more memory oh, really? I am wondering how is it possible at all to store n/2 elements in the heap (for n=250k we use 32 bits times 125000 / 2^20 and thus we get approximately 3.815MB) and not to get MLE there. Bits 32*125000 = 4e+6 bits We know that 1Mb = 8e+6 bits So we end up getting 0.5 MB if storing n/2 elements. And exactly 1MB for storing n elements. Edited by author 14.10.2020 17:20 Edited by author 14.10.2020 17:20 Please help. what is test case 8. so that i can verify my answers. I can't find a problem Please, help my code (C++): #include <iostream> #include <string> using namespace std; int main() { int a, b, c, sum, sr, i, n; cin >> n; cin >> a >> b >> c; sum = 0; if (n == 3) { sum = a + b + c; sr = 2; } else { for (i = 3; i < n; i++) { if ((a + b + c) > sum) { sum = a + b + c; sr = i - 1; } a = b; b = c; cin >> c; } } cout << sum<< " "<<sr;
return 0; } In Russian version there is a mistake in the constraints of h. Must be 200, not 260. for n=2,k=3 ans=2*(2-3)*(2-6)*(2-9)*..... The author must include the condition that n>=k.. I coded O(n^3) that was accepted fairly easy... But I know there is O(n^2) algo but I don't know how to implement it.. Any Ideas? Yaa i have the idea of O(n^2).First you can can calculate the slopes of all lines in O(n^2).Create a class which contains the 2 points and the slope of the line joining two points.Note that there will be n(n+1)/2 nodes and define operator == as: slopes are equal and one point must be common to both the lines. I have tl with long double and wa with double on that O(n^2) solution Edited by author 13.10.2020 05:01 There only 10 situations!!!!! //1. in //2. input //3. inputon //4. inputone //5. out //6. output //7. outputon //8. outputone //9. puton //10. one Check their in inverse order. bool check(char const* s){ while(*s != '\n'){ if (s == "one") s += 3; // there s == "one" only pseudocode, you may check // as memcmp(s, "one",3) == 0 else // ...... //............. // 10 times else else if (s == "in") s +=2; else return false; } return true; } thnx a lot c_pp atleast i learn something what a question haha. just read the question carefully I got tl5 using recursion solution, and i dont know how to optimize it. Please give me some hints how to solve it better Is there any polynomial time solution? > Is there any polynomial time solution? yes. - if there is a cycle the answer is always "yes" - if there is a knot (ex. 2 2 edges), the answer is also "yes" - if graph is multigraph, yes too if all above is false just find the longest path in a tree and play with it's value in comparsion with route length > > Is there any polynomial time solution? > yes. > > - if there is a cycle the answer is always "yes" > - if there is a knot (ex. 2 2 edges), the answer is also "yes" > - if graph is multigraph, yes too "multigraph" : what is it? I got WA so many times,any trick? > > if all above is false just find the longest path in a tree and > play with it's value in comparsion with route length > > Thanks. I did not read the question well enough and thought that the race must start and end on vertices. How stupid of me! That is why I asked that stupid polynomial question. > > > Is there any polynomial time solution? > > yes. > > > > - if there is a cycle the answer is always "yes" > > - if there is a knot (ex. 2 2 edges), the answer is also "yes" > > - if graph is multigraph, yes too > "multigraph" : what is it? I got WA so many times,any trick? > > > > if all above is false just find the longest path in a tree and > > play with it's value in comparsion with route length > > > > Edited by author 23.07.2008 05:54 > "multigraph" : what is it? I got WA so many times,any trick? multigraph can have more than one edge connecting 2 vertices. Those edges can have different length. So, if there are two or more edges, connecting 2 vertices, this is just another cycle. This task is quite tricky and not well-right from the point of diskrete maths. For example, non-oriented graph can not have knots (by the difinition), but in this problem this is one of the "triks". but how to judge whether there's a cycle? do DFs and if there a return edge than u have a circle or do n Dijkstra's and if u can get back to the point than u have a circle I can't understand why if there is cycle, the answer is always yes -> what about this test: 3 3 1000 1 2 3 2 3 3 1 3 3 Edited by author 21.07.2009 12:43 Because there is a cycle with length 9, and we can ride this path unlimited number of times. "The race may start and finish anyplace on the road" I have been trying to solve this problem for several days, but suddenly I ran out of ideas. Could you give me some hints on the task? I have tried brute force and some pruning, but it got TLE. I would be really happy! :) I've got AC! The main observation is that no two queens can be in the same row or column. Thus, we make an array perm[i], which stands for queen in the ith row and perm[i]th column. The problem is to find the number of permutations, which differs from the initial by 3 elements and check for each possibility whether we have conflicts on the diagonals. perm[i] is the initial permutation. I hope this hint was helpful! Please, tell me what is in Test4??????? I also got WA for test 4.....so I started to try some self made test cases.....and I came across this one : 5 4 2 0 1 3 My output : NO. Correct Output should be YES. I will have to rethink my approach.....maybe you have the same problem as well. case 3 3 1 2 3 helped me in test 4. But anyway it's better to write your own test case generator. Edited by author 18.04.2020 04:47 I did not understand this problem firstly .But after 3rd trial i get amused!. Read the problem statement carefully. Its a very realistic,practical and easy problem. Draw a picture to help yourself for finding the solution. Keep in mind that the worm will move leftwards or rightwards from its initial position according to input of starting volume and ending volume. It is also possible that the worm started and ended in the same volume... Happy Coding...:) First i did not understand this problem.but your suggestions help me.thanks!!!And it is really very practical, realistic and easy problem!! a=float(input()) b=float(input()) c=float(input()) k=a*b*c*2 print(k) If the worm starts from the first sheet of the first volume and finishes at the last one of the second volume, how could the answer for the sample input be 2, given that the thikness of the book (not including the cover) is 10? Worm can move both left and right. Stop for a while and think about it. In some languages, the "first page" of a book is on the left side of the book when the book is placed on a shelf. In which case "10 1 1 2" == 22. Just take two books and try - you will find answer immediately I fully agree with you.How could the answer for sample input be 2. I have got AC on this problem. In the description, it says "accuracy to 0.0001". In the code which I submitted, I use printf("%.4lf\n", min_breakage); to match the point. When I use the sample input, my output is 3.0000. But the sample output is 3. So I think the sample output may be wrong. Or both the two outputs are correct? |
|