Общий форумi've got a data:array[0..80000] of longint for save numbers and got AC! why there aren't tests like 100000 operators: 100000 PUSH 1 1 PUSH 1 2 ... PUSH 1 100000 ? funny: data:array[0..100000] gives MLE 1 data:array[0..50000] gives WA 16 data:array[0..90000] gives WA 10 data:array[0..80000] gives AC... Can anybody give me an idea(push) how to solve this problem using interval tree? Thx Если программа, которую выводит моя программа, работает дольше 1 секунды, какой вердикт я получу? I`ve got WA3 too. Can anyone explain what that means? Excuse me, I have next problem: I have got 'compilation error' twice because of using function round() from library 'cmath'. But it works normally in Code::Blocks on my PC. What is the problem and how can I substitute round function? Andrew Hoffmann aka SKYDOS [Vladimir SU] Re: round, c++ [2] 7 авг 2010 19:29 а что именно в сообщении об ошибке выдаёт компилятор? 941ef0f3-e7a3-4f31-a9b3-5be1b580cf1b 941ef0f3-e7a3-4f31-a9b3-5be1b580cf1b(48) : error C3861: 'round': identifier not found > how can I substitute round function? I'm not sure about all these tricks, but this may work: > double d; > int x = (int)(d+0.5); For me round worked just fine, but last time I had used it before compiler was changed. Btw, what compiler do you use in code::blocks? GCC? As they changed the compiler, I tried to re-submit some of my solutions, (in order to get a higher rank in the Rating page :) ) In that problem 1100, there's lots of I/O staff, so I wrote a brief function to accelerate. Generally, it tried to in/output numbers by characters, using getchar() and putchar(). It did work. However, I find the result now very disappointing. Previously 0.046s, but now 0.291s. Even slower than to use scanf() and printf() !! I don't know why this happens, but I hope there's some way to improve... I don't really like this VC compiler thing... I think the old Intel one is much better. Don't use cin && cout. Use scanf and printf Edited by author 07.08.2010 13:47 Yeah I use C not C++. On most occasions it doesn't really matter 0.1s or 0.5s but sometimes I just wanna be a little quicker :) Why there is no koefficient for these two languages? Yes, we know that these langs are a little bit slower then C++/C/Pascal, but why not to add some multiplier(коэффициент, множитель) for java/c# when counting MLE/TLE? I think it will be fair, 'cause really some of us (may be not some, but a big half) doesnt know C++/C and they dont need to learn them, 'cause they (for example) participate in contest like TopCoder, CodeForces where solution always possible in any language(dont speak about script langs on CodeForces). So maybe some good changes? PS. I thought about this trying to solve problem "Stacks" ( http://acm.timus.ru/status.aspx?space=1&num=1220&author=73720 ) in C#... but its unreal to get even 500KB (my empty program, without any vars, structs and so on uses ~800-900KB) But if substract for example 700kb from these 800-900 we have 100-200 kb empty working program on C#, so maybe its possible to solve some low memory problems using right technics. Thx for reading and responding :) Edited by author 05.08.2010 13:03I don't think that coefficient for time is really needed because running time heavily depends on judge system (same solutions get different time) but it's a good idea to substract a blank solution memory usage and also to show memoru usage with precision to bytes. It opens new horizons for fighting for bytes and program optimization. Edited by author 06.08.2010 02:51 About time: the fastest solution on C# runs 0.078 (0.093), JAVA (0.078) its much more than C++ (0.015) ans Pascal (0.031), so why not to stabilize runnig time for all langs? and about memory: yes, substracting memy I think is good idea and it really opens new horizonts for challenging solutions in any language! Waiting for admins and their opinion. I don't think that coefficient for time is really needed because running time heavily depends on judge system (same solutions get different time) but it's a good idea to substract a blank solution memory usage and also to show memoru usage with precision to bytes. It opens new horizons for fighting for bytes and program optimization. Edited by author 06.08.2010 02:51 Timus Online Judge always subtracted some constants from memory result. Current constants (aprox.): C and C++ 0.6 MB Pascal 1.2 MB C# 9.9 MB Java 12.2 MB C# solution that contains only one infinite loop uses 57 KB of memory. OMG! I want to look at this solution! Is it without any "using System.Generic" and other libs? PS My empty "A+B" has 393Kb, but its EMPTY... even without any loops or read/write-data functions. Cant get AC with memory lower then 581kb ( http://acm.timus.ru/status.aspx?space=1&num=1000&author=73720 ) Bad... very bad... this means that its impossible to solve problem @Stacks@ on C#. :( C# solution that contains only one infinite loop uses 57 KB of memory. Edited by author 06.08.2010 18:48public class sum { public static void Main() { while (true); } } OMG! It really takes only 53-57Kb.... The main problem is in Console.Write!! When I use it memory raises to 596-600Kb!! Without it - 53-59Kb... No words, just emotions... WTF? maybe there are some other methods for reading/writing data wich are faster then Console.Write? Thanks. public class sum { public static void Main() { while (true); } } Edited by author 06.08.2010 19:59I've added /o+ switch to csc command line. I've fixed memory constant in such way that infinite loop uses 53-57 KB again Edited by author 07.08.2010 01:46 Понятно. Ну да, теперь уже нет выиграша в памяти, видимо отнималось от тех 690-720кб 57кб и поэтому получали 565-585кб . Теперь и этого нет. Блин, жалко, что такие проблемы с памятью. упс... sorry for russian version. I've fixed memory constant in such way that infinite loop uses 53-57 KB again Edited by author 07.08.2010 01:46 Edited by author 06.08.2010 21:26 depends what you need. you can do so: string s="", g = "andrew"; int len = 6; for(int i=len-1; i>-1; i--){ s+=g[i]; } Well, you can use whatever you want. For example, std::reverse or your own bicycle. :) Cebiyev_Ferhad_Qafqaz U. No subject [2] 7 авг 2010 00:33 Edited by author 07.08.2010 17:42 By telling so he meant that you are trying to invent something that have been already invented :) Edited by author 07.08.2010 00:45 Cebiyev_Ferhad_Qafqaz U. No subject 7 авг 2010 00:39 Edited by author 07.08.2010 17:42 Edited by author 06.08.2010 13:36 Edited by author 06.08.2010 14:20 I know it. But my question is: Is acm allowed me to use such things. why not? Edited by author 06.08.2010 14:03 OK.Thanks.But,will it be wrong, if i called it long aritmetics. Edited by author 06.08.2010 14:20 Nope. OK.Thanks.But,will it be wrong, if i called it long aritmetics. Edited by author 06.08.2010 14:20 Great hint!!! Some algos do not depend on this property Andrew Hoffmann aka SKYDOS [Vladimir SU] С# and Memory [3] 3 авг 2010 21:14 Is it possible to solve some problems using less then 1 MB in C# ? I tried 1010 problem to solve, but less then 941 KB I cannot do... :( it's bad... May be there are some tricks to lower memory consumption ? Thx. PS If code neded - just say, I will show.. maybe some ideas will appear. Edited by author 03.08.2010 21:17 You can run garbage collector manually: GC.Collect(); It helped me to solve problem 1269 where memory is very limited. But don't do so too often - this trick eats much time! Thanks for idea! Is it possible to solve problem @Stacks@ using this trick? Have you tried? using System; using System.Collections.Generic; namespace Task_1020 { public class Program { private struct Point { public double X { get; set; } public double Y { get; set; } } public static void Main() { Point nR = Read(); double n = nR.X; double r = nR.Y; var points = new List<Point>((int)n); for (int i = 0; i < n; i++) { points.Add(Read()); } double l = 2*Math.PI*r; if (n == 1) { Console.Write(String.Format("{0:f2}", l).Replace(',', '.')); } else { l += ComputeLength(points[0], points[(int) (n - 1)]); for (int i = 0; i < n - 1; i++) { l += ComputeLength(points[i], points[i + 1]); } Console.Write(String.Format("{0:f2}", l).Replace(',', '.')); } } private static double ComputeLength(Point p1, Point p2) { return Math.Sqrt(Math.Pow(p1.X - p2.X, 2) + Math.Pow(p1.Y - p2.Y, 2)); } private static Point Read () { var twoNum = Console.ReadLine().Split(' '); twoNum[0] = twoNum[0].Replace('.', ','); twoNum[1] = twoNum[1].Replace('.', ','); return new Point {X = Double.Parse(twoNum[0]), Y = Double.Parse(twoNum[1])}; } } } OMG man! What a F*** code!)) What for these things are: Replace(',', '.') ???? you can read two double vals: double[] point = Console.ReadLine().Split().Select(s=> double.Parse(s)).ToArray(); x = point[0]; y = point[1]; try it! Thanks for your replay. The problem was in this F***ing Replace.. =) and hey.... what is this??? "Console.Write(String.Format("{0:f2}", l).Replace(',', '.'));" ???? write just: Console.Write("{0:F2}", l); Random shuffle of matrix`s rows help me to avoid TLE Someone who solved this problem, give some ideas, please. The answer is n^2 + floor(n/2) + 1. Place n^2 in top-left corner and proceed row-by-row, column-by-column. For every cell choose maximal unused value, such that its sum with left and upper numbers is <= that minimal sum. I have no idea why that works. The formula above was found empirically - these are minimal values when this greedy algorithm converges. Edited by author 24.07.2008 15:00 Real cheat! With this formula the problem is VERY easy! IMHO, without it - it would take much more time and efforts to get AC. If you encounter any problems please describe it in this thread. Thanks a lot! Waiting for C# upgrade! PS and dont forget to import(add reference) System.Numerics :) Can you please describe the most significant changes in this compiler compared to previous one? well.. I'm very glad to find that an additon "system("pause")" in the last line won't lead to WA still. (Otherwise we may encounter lots of WAs if there's rejudge...) However, I noticed that there's a slight difference in the memory usage indicator. A+B Problem, for instance, previously they're 121KB for both C/C++. They are actually 104/188KB now. It's not a very critical problem after all :) I'm just a bit afraid that we may have to change a little bit of our "code style" to fit with the new compiler... Then go for it~ Bytewise reading now works slower than scanf. Thats the first thing I've noticed. 1) I used Dictionary<,> and had crash 4, 'cause there were equal words. 2) For example you have two(three) words like: akt blu ckv *they all have code 258, so you can take any of these words. These two "bugs" after fixing gave me AC with 0.14 time and ~9MB on C#. Good Luck. Edited by author 04.08.2010 14:08 I got AC with interval tree. but it's so painful coding it. How to do it with segment tree? The range is too large... please help. thanks in advance to make it "discrete", is that the right word? i mean, we only care the points mentioned in the input. Edited by author 04.08.2010 05:18 Can anyone tell me what does the problem say in short ? This problem is too long to read...-.-" Just read only two last paragraphs of statement. I thought that we must do with heads (n) next: 2*2*2*...*(n div 2) ---> for odd(n)=false and 2*2*2*...*3*((n-3) div 2)---> for odd(n)=true. What why answer for n=: 5-->2*3=6 6-->2*2*2=8 7-->2*2*3=12 8-->2*2*2*2=16 9-->2*2*2*3=24 but when I write solution, a saw that ans for 6=3*3=9(not an 8), for 9=3*3*3=27(not a 24). COULD YOU HELP ME WITH RIGHT IDEA? Edited by author 29.05.2006 18:25 The last number must be 3,and others must be 2.So you have to judge whether n is an odd number or an even number first.This step is very important.And the n must be: n=2+2+2...+3(if n was an even number,there is no 3.) if n mod 3=0 then ansver is 3 in pover (n div 3); in other cases answer is 2*2*2*...*3 if n mod 3=0 then ansver is 3 in pover (n div 3); in other cases answer is 2*2*2*...*3 3*3 > 2*2*2, so your assumption is wrong. The answer is 2*3*3*...*3, when n is even and 3*3*...*3 otherwise. for 8-->3*3*2=18(not a 16) Edited by author 03.08.2010 17:40 Answer is a simple multiplication: 3*3*...*3. If n % 3 == 2, then it ends with ...*2*2. It's somehow linked with E, but how? If n could be divided on rational numbers, then the max product will be always (n/k)^k, where k is integer, such that abs(n/k - E) is minimal possible value. It is a well-known theorem. does anyone know what's the Test 5 ? Or can sent some tests. Thx Try to find minimal and maximal distance between figure's center and border, and think about possible shapes. |
|