| Show all threads Hide all threads Show all messages Hide all messages |
| hint? | coder | 2057. Non-palidromic cutting | 25 Jul 2026 15:15 | 1 |
hint? coder 25 Jul 2026 15:15 minimum is always -1, 1, or 2 ? 1) S = aaaa...aa => -1 (S = [a]*n) 2) S = aaabaaa on center different symbol ==> -1 (S = [a]*m + 'b' +[a]*m) 3) S = ababababa...ababa ==> -1 (S = [ab]*m + 'a' there S is palindrome) 4) S - is not palindrome, ==> 1 5) S - is palindrome, there at least two different symbols => 2 Proof 5: let a = S[1], b = S[i] , and all S[1] = S[2] = ..=S[i-1] = a, There S is palindrome. S = aaaabxy....baaaa Take T1 = aaab T2 = xy...baaaa T1 - is not palindrome 5.1) T2 also is not palindrome, minimum cut is 2. 5.2) T2 also palindrome 5.2.1) i > 2, there two or more 'a' in T1. T1 = aaabx T2 = y....baaaa There T1 and T2 both are not palndrome, (think about it). 5.2.2. i = 2. T1 = ab But T2 palindrome, so S = abababababa...aba, this can't be allowed, because S != [ab]*m + 'a' already checked.
|
| help with 52 pls | 🎧 Vadim Barinov \Frez_Fstilus/'` | 1509. Domino Recognition | 24 Jul 2026 22:20 | 3 |
What may cause this judgement result? I think there is an error in your domino size cheking function or something similar. See your other topic for details. Thanks a lot. I really returned to this problem 9 years later and mistake was staring me in the eye. I didn't check min distance for 0-2 and max distance for 1-1. |
| I don't understand what I'm doing wrong anymore. | lain | 1001. Reverse Root | 24 Jul 2026 12:38 | 1 |
import sys, math numbers = [] empty_lines = 0 for line in sys.stdin: line = line.strip() if line == "": empty_lines += 1 if empty_lines == 2: break else: empty_lines = 0 numbers.extend(line.split()) for num in reversed(numbers): print(f"{math.sqrt(int(num)):.4f}") |
| The real solution | Huang Da | 1789. Searching for the Dodecahedron | 24 Jul 2026 12:03 | 2 |
Don't know why so many authors have posted 2*n-1.. That's obviously a wrong solution... Just think about if the stone is in the odd and the man touches the odd, things will be done smoothly. The real solution is writing a "checker" for this problem, and then BFS over possible states from 2^n-1 to reach 0 (on bitmask of where it can be located). That produces a nice pattern which is always 2*(n-2), and ofc. shortest possible since it's fair BFS. 2 3 ... n-2 n-1 2 3 .... n-2 n-1 for odd N 2 3 ... n-2 n-1 n-1 n-2 ... 3 2 for even N |
| WA7 | Solver | 1789. Searching for the Dodecahedron | 24 Jul 2026 11:59 | 1 |
WA7 Solver 24 Jul 2026 11:59 |
| I have AC with such idea but I don't understand how to get a formula or faster solution | IlushaMax | 1023. Buttons | 24 Jul 2026 10:48 | 4 |
var i,n,l,j:longword; found:boolean; begin readln(n); repeat found:=False; for j:=3 to n div 2 do begin if n mod j=0 then begin found:=True; break; end; end; if found then n:=j; until not found; writeln(n-1); readln; end. Please help me to optimize my code. It's 0.405 sec for j := 3 to sqrt(n) do will help you :) > for j := 3 to sqrt(n) do will help you :) will it? for sqrt(8) = 2.8, but answer should be 4 - 1 = 3 Two eparate loops for n%prime (prime>2) and n/2%prime if n%2==0 |
| What is your idea of solution? | Vedernikoff Sergey (HSE: EconomicsForever!) | 1658. Sum of Digits | 23 Jul 2026 11:12 | 4 |
Mine quite straightforward realization works about 1 sec. and uses almost 60 megabytes of memory. Please, give an idea how to solve it more quickly... Edited by author 17.03.2010 14:10 Struggled with WA2/WA4 for a lot of submits. Tricks are tracking min-length and even then getting least possible value can be tricky. My solution is DP(900*8100)*9 to get minimal length. Then greedy BACKtracking from higher to lower using least possible digit (so you get as many '1' as possible, then as many '2' and so on) over edges that follow minimal length path. As for memory - two arrays of uint8_t. That's 14Mb. You can also sacrifice backtracking array, and perform it on the fly during generating output, would be bigger runtime, but half the memory. |
| at last i solved it | Rustam | 1658. Sum of Digits | 23 Jul 2026 10:23 | 2 |
i have +27 submites on it just because i forgot tests like that: 1 808 6464("No solution") Edited by author 10.10.2009 04:16 |
| Для тех, кто не понял | 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/00UUdf Edited by author 23.07.2026 09:22 |
| 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. |