Common Board| Show all threads Hide all threads Show all messages Hide all messages | | Для тех, кто не понял | Daulet | 1740. Deer is Better! | 21 Jul 2026 11:57 | 5 | Скорость оленей не ограничена, т.е. они могут хоть телепортироваться считай Здесь факт лишь в том, что они должны пробежать за H часов K километров По этому минимальное например при данных 30 11 2 будет равно 4 Объясняю: За 4 часа олени пробегут 22 км (ну, 11*2 просто) , и так как осталось 8 км, то они могут это расстояние просто перелететь (телепортнуться), ведь это меньше 11 км, поэтому им и время не нужно (они же не прошли 11, значит и 2 часа не нужно). А с максимальным все очень просто, это просто время если бы олени двигались с постоянной скоростью, но могли немного перебежать нужное расстояние(главное чтобы оно было не больше к) При 30 11 2 макс время будет 6 часов, тк только тогда олени достигнут своих 30км изначальных (ну немного больше пробегут - 33 км) Надеюсь кому-то поможет в решение The problem is just from Russia. Pay attention, the Chukchi is running, not an Eskimo, not an Indian, but a Chukchi. And in Russia everything is relative. And the position of the Chukchi is relative. That is, the Chukchi is located somewhere in the Yamal-Nenets district. On the territory within a radius of 100 kilometers from the telephone tower. In 2 hours he will be in an area within a radius of 100 kilometers from another telephone tower. That is, he will reach Moscow in 4 hours, plus or minus 2 hours. Something like this. Translation problems. Что-то ваши объяснения не очень логичны. Вы уверены, что именно эта логика заложена авторами задачи ? | | Any Help/Hint | Amil Khare | 1142. Relations | 21 Jul 2026 11:40 | 6 | Hello, I am not that strong in DP but I have been trying hard to understand the problem. I tried coming up with a solution however got WA. I cannot completely understand the hints given before, PLEASE HELP !!! There are two dp-approaches already described on the webboard So I have accepted with dp I have two dp Stirling numbers of the second kind and factorial Then precalculate answer array I have seen the 2 DP solutions however I still don't understand how do they arrive at the relation? Can you describe in detail if possible, Please ! There are X groups consisting of equal numbers. X=1,2,..n. What does it mean, to put some '<' and '>' signs between them? It is just to define some order relation. Just assign one group as the greatest, another group as the second greatest etc. So we find number of ways to make groups and multiply it by number of ways to make ordering https://ideone.com/00UUdfJust brute force precalc :) offline ofc, it gets quite some time for n=10 bool t[16] = {}; int res[16] = {}; function<void(int, int)> step = [&](int pos, int prev) { if(pos == n) { res[n]++; return; } for (int i = 0; i < n; i++) // '<' if (!t[i]) t[i] = true, step(pos + 1, i), t[i] = false; if (pos) for (int i = prev + 1; i < n; i++) // '=' if (!t[i]) t[i] = true, step(pos + 1, i), t[i] = false; }; for (n = 2; n <= 10; n++) step(0, -1); | | Strange printf behavior | it4.kp | 1461. Christmas Garland | 21 Jul 2026 11:28 | 12 | Strange but when i use printf("%s",s.c_str()); I get WA on test 11, but if change it to cout<<s; it's become AC. Can somebody tell me why? Well, I got WA 3 during the contest but I'm pretty sure my idea is right, ahy tests ? I first, have WA3 too. That was because I misunderstood the problem statement... I thought that there cannot be two consecutive segments with y=0 which is wrong. Please help me. I still get WA on test 3 I'm a loser :( Edited by author 31.07.2007 15:38 I don't know why you have WA, but even if you fix all your bugs you definetly get TLE, since next_permutation works in exponential time and the length of string could be 100000! Give me some tests please I've WA #3 P.S. And what about tests with N = 1? Here are some tests Test 1: 4 uudd Answer 1: No solution Test 2: 4 uhhd Answer 2: uudd Test 3: 8 udududud Answer 3: ududuhhd Test 4: 32 uuuuuuuuuudddddduuuuuudddddddddd Answer 4: uuuuuuuuuudddddhdddddududududuhd Test 5: 41 uuuuuuduuuuuddddddduuuuuuuuuhdddddddddddd Answer 5: uuuuuuduuuuuddddddhddddududududududududud Test 6: 15 uuuuuuuhddddddd Answer 6: No solution p.s.: there is no tests with n=1. EDIT: Test 5 is correct now Edited by author 13.08.2006 22:01 Thanks for the tests, it turned out that I have misread the problem :(, anyway, thanks for your help Just feed output as input till it's "No solution" and see results. It might help finding bugs. Thanks for the tests! 4th helped with WA3 to get AC. I considered that 'h' is not allowed at y=0 in if-you-can-finish-itr (that is n==1 && y==0 -> false), but forgot to check for y=0 on 'h' in incrementer/finisher loops. | | WA 17 test | anotherworld | 2214. Quality Emitter | 20 Jul 2026 15:27 | 1 | 4 3 2 3 9 3 7 9 5 3 8 3 8 2 0 5 answer : 62 | | AC with Pollard's rho algorithm | Keworker `~ | 2102. Michael and Cryptography | 20 Jul 2026 12:02 | 4 | I pass this problem with Sieve of Eratosthenes, but i think solution with Pollard's rho algorithm is funnier, and wrote it too. If you cant pass it with this algo just use all prime modules from 1'000'000'007 to 1'000'001'393. Did you check small dividers? ro pollard works very poorly with them If TL let me check all with O(sqrt(n)), I do it. I invoke rho pollard only if can not pass test with O(sqrt(n)) Sieve up to 1e6 - WA54 Sieve up to 1.5e6 - WA59 Sieve up to 1e7 - AC :) | | What's your algo? | ACSpeed | 1604. Country of Fools | 20 Jul 2026 11:31 | 6 | Can you guys share your approach ( and proof if possible ) because mine, though AC, is not very certain. I rely on greedy approach which output pairs with maximum number and minimum number. Use sort and find min and max after output each pair. Quite slow, 0.14s :) Greedy approach is fine but why output pairs with maximum number and minimum number ?? Can you guys share your approach ( and proof if possible ) because mine, though AC, is not very certain. I rely on greedy approach which output pairs with maximum number and minimum number. Use sort and find min and max after output each pair. Quite slow, 0.14s :) I used a max heap in which I hold pairs like, number i (index of the sign) and frequency of that sign. Each time I pop out from that heap the 2 index with maximal frequency, decrement their frequency and update the heap from their indexes. I was sure that there is a more simplier aproach to that problem(like greedy), without using heap, but I was just 99.9% sure that with heap I will got AC, and so it was. :) The same here. I'm using heap, but I'm pulling entries one by one, decrementing and not adding them back until next entry is pulled. I was 146% sure this would work when I decided to implement this algo and it not that bad in terms of time: O(n log k). But I wondered if there is a simple straightforward algo that also would work. Turned out there is. I created an array of pairs (quantity, index) and sorted it. Output the maximum and the next one with a positive quantity, and if there are elements with the same quantity that remains at the maximum, I output them the same way, each step decreasing the number of the output element Sorry for my English tests with my answers: 4 8 5 4 3 1 2 1 2 1 2 1 2 1 2 3 1 3 4 1 3 4 1 3 4 5 9 7 4 4 3 1 2 1 2 1 2 1 2 1 2 1 2 4 3 1 2 4 3 5 1 4 3 5 1 4 3 5 Pick maximum according to remaining amount which is not equal to previous sign, heap is enough for that (though I got 0.125 AC with O(N^2) when tested this approach). Heap gave 0.015 Edited by author 20.07.2026 11:41 | | WA #11 | Solver | 2074. Timus problems classifier | 18 Jul 2026 11:26 | 1 | WA #11 Solver 18 Jul 2026 11:26 When I sorted all problem according to their set of topics for merging at output I forgot to make it stable, so that the order of grouped problems stays increasing. | | That's crazy | andreyDagger`~ | 1775. Space Bowling | 18 Jul 2026 10:25 | 2 | #pragma GCC optimize("Ofast") With this line of code I'm getting AC 0.468, without it I'm getting TL14 gcc has problems when it uses FPU | | new task | Dmi3Molodov | | 15 Jul 2026 05:02 | 1 | 2^8 queries are given. Each query has an interval [L,R). (2^63<L,R<2^64) Find the number of primes in each interval. P.S. Warning: you won't fit into a hundred lines of code! | | right answer for test? | ilya trofimov | 2013. Neither shaken nor stirred | 14 Jul 2026 10:11 | 3 | 2 0 1 2 1 1 1 ------- unknown unknown unknown 1 or 1 1 1 1 Before first visit pub #1 is asking about drinks? unknown unknown unknown 1 Beacuse he doesn't know whether he drank 1 or 0 cocktails last time. And, yes, he will be asked first time. That also means that the trip doesn't stop when answer is unknown | | WA3 | andreyDagger`~ | 2013. Neither shaken nor stirred | 14 Jul 2026 10:10 | 2 | WA3 andreyDagger`~ 10 Jan 2023 20:54 Test: 10 2 3 2 3 6 0 1 1 0 2 4 10 0 3 5 7 9 0 1 3 0 1 3 0 1 8 0 1 7 1 1 7 2 1 5 Answer: unknown 2 2 2 2 2 2 2 2 2 2 2 unknown unknown unknown unknown 2 1 2 2 This test looks incorrect as they can't reach any bar after 1 | | Algo? | melkiy | 1689. Fisherman and Barbell | 14 Jul 2026 08:29 | 4 | Algo? melkiy 6 Mar 2009 04:35 My step-by-step barbell moving (though improved to add into under and out under the barbell only "right" worms without checking every worm) gives TLE on 8th test. Is segment tree needed? I solved without it.I also used "improved step-by-step barbell moving",but my solution was quite far from TLE. I modeled groove as int array,but if you use sorting on worms array and then search there some coordinates then you can possibly get TLE. Edited by author 06.03.2009 05:20 I solved this problem without sorting. I found difference d[this_step]=count[this_step]-count[prev_step], and after that count_squash_worm=count_squash_worm+d[this_step]. Edited by author 09.03.2009 15:06 Just slide ahead and once you step on a worm by left or right plate, increase number of times that worm was stepped on (that number will drift between 0, 1, 2). When number of plates intersecting the worm changes between 0 and 1, total amount of affected worms changes accordingly. This algo can support overlapping worms and 1e+9 coordinates with sorting of worm endpoints. | | Some info about this problem | Olzhas aka Whale2dy | 1030. Titanic | 14 Jul 2026 07:37 | 11 | Hello, everyone. Just wanted to summarize some info about this problem. Ok, my code got AC with following things in it: 1. My pi was 3.1415926535897932384626433 (perhaps it is enough) 2. I used this formula from wikipedia deltaArc=acos(sin(phiA)*sin(phiB)+cos(phiA)*cos(phiB)*cos(deltaL)); distance = deltaArc*3437.5; (see the first formula from wikipedia http://en.wikipedia.org/wiki/Great-circle_distance)3. I used the following condition: if(100.00-distance>0.005) printf("DANGER!\n"); Hope it will help somebody. thanks a lot ...your formula is really useful.^_^ Used everynth what is written here. However still WA8. Any new ideas?... Do u know that pi can be calculated by this formula: atan(1) * 4? Also if you use acos on dot-product to get distance over sphere, beware that acos(-1.000000001) or acos(+1.000000001) will give NaN, so clamp argument to [-1, +1] range explicitly. | | Help WA Test #7 | Varun Sharma | 1030. Titanic | 14 Jul 2026 07:35 | 5 | Edited by author 07.03.2010 10:26 Hi, Alright guys I have solved the problem. Being a newbie to c# caused me to submit program 35 times. I didn't realize that Math.Round() function will change 100.00 to 100 instead. Here are the lines which I changed. double miles = distance(ship_latitude_radian, ship_longitude_radian, iceberg_latitude_radian, iceberg_longitude_radian); if (Math.Round(miles, 2) < 100.00) { Console.WriteLine("The distance to the iceberg: {0:F2} miles.", miles); Console.WriteLine("DANGER!"); } else { Console.WriteLine("The distance to the iceberg: {0:F2} miles.", miles); } Solved by making the following comparison in java: if (Math.round(distance*100) < 10000) { System.out.println("DANGER!"); } it will force it to compare with 2 digits precision. Edited by author 14.07.2026 14:28 | | wrong constant of earth | yyll | 1030. Titanic | 14 Jul 2026 07:11 | 2 | diameter of 6875 miles (/ 2 = 3437.5)??? the mean radius of earth is 6371.0 km (3958.8 miles) Nautical miles are different | | On WA8 | Solver | 1569. Networking the “Iset” | 14 Jul 2026 06:14 | 1 | On WA8 Solver 14 Jul 2026 06:14 You have to check all edges between centroids, not just arbitrary one. Although it leads to O(N^4) due to N^2 BFSes on cliques, early cutoff on max-dist from roots vs. current result makes it almost O(N^3). AC 0.046 sec | | Notice | Solver | 1569. Networking the “Iset” | 13 Jul 2026 11:04 | 1 | Notice Solver 13 Jul 2026 11:04 You may output edge nodes in any order (1 2) or (2 1) checker accepts that | | Who know how the 2nd test looks like?? | Last_Vikings | 1546. Japanese Sorting | 12 Jul 2026 08:40 | 19 | We cannot imagine the test where our prog will give wrong answer! I wonder too, always wa on test 2 1w1 01w01a Edited by author 24.04.2007 19:29 No, its not 2nd test. My prog correctly process it, but stil WA2. sorted: 01w01 01w1 01w01a z000 z00 z00p z0p and one more 0 0p 01 1 1p Edited by author 25.04.2007 20:03 Try this test: z0p z00pp z0pp z00pp00 z000pp01 z00pp01 z0pp01 z001pp00 z01pp00 z1pp00000 z01pp01 z1pp001pp0 z1pp01pp000 I get WA#2 too. Huge thanks to Alexander Kouprin, after running his test and solving the problem I got accepted. Test from Alexander Georgiev also helped me a lot. By the way, my program gives other output for some test from this thread. Here they are: abc00125a abc0125a abc00125b abc0125b abc000000000000000000000125a abc00000000000000000000125a abc0012000000000000000000000000005b abc012000000000000000000000000005b These tests have almost broken my mind while I have been thinking why they are correct and I'm happy that I do not have to fix my program because of them. Zeroes matters only if strings are equal. Try this: abc0125a abc00125a abc00125b abc0125b Try this: abc0125a abc00125a abc00125b abc0125b I suppose the last test by Peter Huggy is the most similar to second test but after all this tests WA6 Try this: abc00000000000000000000125a abc000000000000000000000125a abc0012000000000000000000000000005b abc012000000000000000000000000005b I suppose the last test by Peter Huggy is the most similar to second test but after all this tests WA6 Got AC, thanks to Alias tests :) You can also try: 0000000 000 (Already sorted) Your program must return for these tests next results (alredy sorted): 1) 000 00 0 2) 00 0 000a 3) 00a000 00a0 I don't understand this. Why is 0000000 smaller than 000? What's the logic behind it? Edited by author 12.01.2021 22:30 I think logic behind it is when strings are equal on "japanese" interchanging alpha-numeric sequences, then the whole strings are compared, so that puts 001 before 01 and 002 before 02. Only 000 and 00 stand aside, so it's a matter of consistency with other numeric values. Or think of it the other way - append something like '~' (ASCII 126) to the end of the sting, that will put 001~ before 01~ and 000~ before 00~ | | what mean "lexicographically first compatible pair" ? | dibrov.bor[SumySU] | 1530. Ones and Zeroes | 12 Jul 2026 04:21 | 4 | I try to output zeros in this case, but seems like I'm wrong please show me some example for example for this case 2 11 11 Edited by author 11.12.2007 21:50 This test is correct, and the answer should be 00 00 The test is correct, original sequences do not need to be compatible | | A hint ? | Yosif Yosifov | 1530. Ones and Zeroes | 12 Jul 2026 04:19 | 10 | A hint ? Yosif Yosifov 20 Feb 2007 01:33 Can someone give me a little hint, please ? make 2 sequences (s1 and s2) such that s1[i]+s2[i]<>2 My solution is based on a greedy approach. I think that an algorithm has many special cases. Main rool:to correct firstly s2[i] from 1 to 0 in pair s1[i]=1 and s2[i]=1 diminishing B but have pair 0, 0 in older position correcting it to 0, 1 for final increasing lexiographicly of B Who can find all cases he solve the problem After getting AC i have counted 6 cases next tests correspong each of cases 4 1011 0011 1011 0100 4 1010 0111 1011 0000 4 1011 0110 1100 0000 4 1111 0101 0000 0000 4 1010 0101 1011 0000 4 1011 0100 1100 0000 Edited by author 21.02.2007 13:58 My program successfully passed all of your test cases, but I still WA3... What can it be??? You are need in additional tests Best if you will create them yourself I have only 3 cases 1) attempt to build a >b 2) attempt to build a+1 0 3) build 0 0 A + B = A XOR B iff there is no carry, or in other words A AND B = 0 So the algo is simple Find leftmost x such that p[x]=q[x]=1. if none, assume x=n+1. Find rightmost y to the left of x such that p[y]=q[y]=0. If none, output p+1, 0 (p+1 may become 0). Otherwise set q[y]=1, and q[y+1..n]=0 Edited by author 12.07.2026 04:38 |
|
|