| Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
| WA7 | rohit | 1254. Крепкий орешек | 24 июн 2026 11:33 | 4 |
WA7 rohit 12 апр 2011 03:18 What's special in test 7 ? I tried all the tests given here and I get right answer. My algorithm is to use bfs to calculate shortest path from source to each destination. If destination is reachable, source is updated to destination else source remains same. Anything wrong with my method ? Re: WA7 Erop [USU] 2 май 2011 22:47 may be some problems with precision? Re: WA7 Velea Alex 26 авг 2011 01:41 I got the same problem .. i have WA7 .. I used BFs .. O(n*m*k) with 2 quest .. one for the blocks whose were reached by vertical or orizontal moves ( last move ) and another for those who were reached with diagonal moves (last move counts only again .. ) with this i do not need to use Heap :( but i got a problem .. i triend almoast every test .. and they worked .. but still WA7 .. :( my prog. it's not written so well ... so i will not post it .. if you think that it will help you .. ask for it : ) i will keep in touch with this thread :-S I tried it this way - i.e. propagate all with 1, then with sqrt(2) from current frontier to upcoming edges, but here is the thing: distance 0 leads to 1 and 1.4 (all still fine and sorted) distance 1 leads to 2 and 2.4 (all still fine and sorted) distance 1.4 leads to 2.4 and 2.8 (all still fine and sorted) distance 2 leads to 3 and 3.4 (all still fine and sorted) distance 2.4 leads to 3.4 and 3.8 (all still fine and sorted) distance 2.8 leads to 3.0 and 4.2 (WOOPS! - 3.0 will be placed after 3.4 and 3.8) so I did Dijkstra, but with super-optimization. Instead keeping all nodes in a heap, I kept a heap on unique distances (as of A+B*sqrt(2)), and for each such distance I kept bidirectional list of nodes with that distance as currently reached. This makes edge relaxation O(1) - remove from current list, and add to another. So it's O(N*M)+O(K*log(K)) where K is number of different distances, and there are not so much on the way. Although I checked with asserts, there are cases when you have like 8 or even 16 upcoming frontiers even during first 6 tests. Relexations start happening with test 5, but only test 7 leads to WA on them with too greedy approach. Edited by author 24.06.2026 11:43 |
| First test is correct? | coder | 2188. Они заряжают пушку... ЗАЧЕМ?! | 24 июн 2026 11:16 | 1 |
Why for D = 8 answer is 10? Why 9 is not answer ? indexes : 0 1 2 3 4 5 6 7 8 9 10 prefix-sum of a[1..10]: 0 7 11 18 18 23 29 33 37 42 46 prefix-sum of b[1..10]: 0 5 8 13 14 16 19 22 29 31 31 diff : 0 2 3 5 4 7 10 11 8 11 15 t = 9, diff 11, t = 10 diff = 15 and minimum t which diff >8 is 9. |
| WA 33. What is this wrong? | Vsevolod | 1820. Уральские бифштексы | 23 июн 2026 16:43 | 2 |
a,b=map(int, input().split()) if a==1: print(2) exit() if (a*2)//b<a*2/b: print(a*2//b+1) else: print(a*2//b) Edited by author 23.06.2026 16:44 |
| wa 22 and then mysteriously AC: don't know why? | Radi Muhammad Reza | 1325. Грязь | 23 июн 2026 12:17 | 3 |
when trying to update from (ux,uy) to (vx,vy) i was checking if (vx,vy) was already popped from priority_queue. this got me wa 22 many times. later, just out of frustation i removed the check and let (vx,vy) be updated even after it was once popped. and u know what, mysteriously got AC. of course, there has to be some logical explanation behind that. please explain anyone? Thanks in advance. I followed by your advice, and also suprised! Consider this test 4 5 1 1 4 5 11111 22221 21111 22222 You may get caught by situation that '2' at (3,1) gets way longer walking path from '1' at (3,2) than from '2' at (2,1). I remedied this by traversing both fronts in parallel, so it's still O(N*M) BFS w/o heaps or sorting. Edited by author 23.06.2026 21:29 |
| A test | Sergei Barannikov | 2109. Туризм на Марсе | 23 июн 2026 10:16 | 2 |
A test Sergei Barannikov 12 июн 2020 04:25 4 1 3 1 4 2 4 1 2 4 The correct answer is 1. Thanks :) Forgot to traverse ALL cities between L and R |
| very easy problem if think right | coder | 2195. Бинарные деревья | 22 июн 2026 18:49 | 1 |
Hint: convert first tree some middle special case tree , and from this make isomorph to target tree. |
| I've got WA #7. Can someone give me test #7 please??? | esekkelle | 1901. Космический лифт | 22 июн 2026 00:44 | 4 |
Had the same problem at the beginning, but finally solved it. Good test that helped me to find a bug in my algorithm was: 3 6 2 1 5 When the solution is: 2 (not 3) 2 5 1 Edited by author 24.03.2014 16:32 Edited by author 24.03.2014 16:33 Why two? need to output the maximum amount of trips of the elevator. I dont understand it. Because you can't get three trips here no matter the ordering |
| DP with rerooting | strangequark0 | 1371. Грузоперевозки | 22 июн 2026 00:38 | 2 |
Can be solved using two DFS calls and tree rerooting in O(N) while maintaining a DP array where DP[node] = sum for all paths from node to all the nodes in its subtree (considering 1 as the initial root). Tree rerooting can be used to calculate the sum for all nodes. It's easier to solve by counting in how many paths each edge participates which is v*(n-v) if 'v' is number of nodes in its subtree. So just BFS is enough to get topological order to calc these amounts. |
| Is my idea correct? | Roman Rubanenko | 1182. Team Them Up! | 21 июн 2026 21:55 | 4 |
Hi all. I use dfs to find the number of connected components. If there are 2 components,then i output each of them as a single team.If there is only 1 CC,then i output numbers from 1 to n/2 and from n/2+1 to n. Otherwise "No solution". It seems to me correct,but.... Or tell me some tests that prove my idea's fail) Your idea is incorrect. 1) If 1st person knows 2nd person it doesn't mean that 2nd person knows 1st person. 2) If 1st and 2nd persons know each other and 1st and 3rd persons also know each other it doesn't mean that 2nd person knows 3rd person and vice versa. According to your algo in the first case both persons will be in one connected component, and in the second case all 3 persons will be in one connected component. Hi, I think that you should find the strongest connected components in a digraph. No, it's about finding two cliques |
| WA 11 | IvanShafran | 1158. Censored! | 21 июн 2026 21:52 | 2 |
WA 11 IvanShafran 14 окт 2014 20:30 If you use Aho-Korasik+DP you should delete forbidden words which contain other forbidden words. Example: alphabet = "01" forbidden words = ["100", "10", "11"] -> forbidden words = ["10", "11"] Aho-Corasick has "dictionary" edges for this purpose, so if bad[suffix[i]]==true, then bad[i]=true. Ignoring words that contain other words also works, but it's not true O(N) :) and there is pitfall of some word like "AB" being listed twice and cancelling itself out, so if you go checking for substrings, make sure that the other word is strictly shorter. |
| I have some test datas | zzyzzy12 | 1158. Censored! | 21 июн 2026 21:21 | 3 |
50 50 10 qwertyuiop[]\asdfghjkl;'zxcvbnm,./ QWERTYUIOP{}|AS aegaegu etoijqt tquqi witowwt zxcjnc oeit potieq iojge nvoq piqper ans=8881647922834867244791415981705771412427494861672253136057167374729235842468240763290 1 1 1 a a ans=0 5 10 3 abcde abc bc c ans=1048576 Edited by author 05.04.2012 20:51 - Edited by author 07.01.2024 21:19 All is well except space in alphabet, replace with * |
| Для тех, у кого нет идей к решению | Alexey Shestakov | 1044. Счастливые билеты. Easy! | 20 июн 2026 15:53 | 1 |
1) Стоит рассмотреть, какие суммы мы можем набрать с помощью n \ 2 цифр билета (от 0 до 36, в случае с n равным 8) 2) Когда мы нашли количество сумм размера n, находим ответ, складывая их квадраты Почему квадраты? Пусть у нас n сумм размером k. Это значит, что мы можем сопоставить в пару к первой сумме вторую, третью, ..., n - 1 и n. Со второй и последующими - аналогично |
| Imagine yourself a statement | Igor Parfenov | 2017. Меньшее из зол | 20 июн 2026 00:28 | 1 |
1. The given graph of "two people contradict" is bipartite (good don't contradict each other and bad don't contradict each other). 2. If two people saw third person in different places, these two people contradict. Edited by author 20.06.2026 01:29 |
| No statement | Igor Parfenov | 2021. Страшно интересно! | 19 июн 2026 22:58 | 1 |
So, what is the statement? What am I asked to find? I guess, to minimize the suffix, such that difference of score at the beginning of it is greater (or equal?), than six times length of the suffix. |
| "Hint" | Solver | 2225. Гвозди в доме | 19 июн 2026 21:23 | 1 |
"Hint" Solver 19 июн 2026 21:23 There is O(N*log(N)) solution with O(N) memory, and only due to sorting |
| HINT | __Andrewy__ | 2167. Шифровка 5 | 19 июн 2026 17:53 | 2 |
HINT __Andrewy__ 31 дек 2023 11:49 There is O(sieve) + O(2*2^20) preparation (CPU/RAM) + N*O(20) per query algo for arbitrary numbers, not just primes. Use a heap-alike array where left edge corresponds to setting bit 0 (from highest to lowest) and right corresponds to settings bit 1. Internal nodes tell if you will eventually find prime (or anything else) on that way. Edited by author 19.06.2026 17:53 |
| Need to add another test — currently it's possible to get Accepted with a partial solution | bdm | 1930. Машина инженера Ивана | 19 июн 2026 15:12 | 1 |
For example: text 5 5 1 2 2 4 3 4 1 3 3 5 2 5 Optimal route: Start with the 'down' gear. 2→1: go downhill (0 shifts, gear stays 'down'). 1→3: go uphill → 1 shift (gear becomes 'up'), score = 1. 3→5: go uphill (0 shifts). Total: 1 shift. My algorithm outputs 2 because it doesn't account for the current gear when storing distances. Nevertheless, I got Accepted. |
| hints (Nostradamus advised this) | Dmi3Molodov | 1102. Странный диалог | 19 июн 2026 13:48 | 1 |
1) Start with the FOUR final states. 2) Use only 15 states. 3) If it doesn't work out, then read the hint further. unsigned char constexpr stopStates = 4; auto constexpr go = []() {//state machine (2D array) std::array<std::array<decltype(+stopStates),256>,15> g; for(auto&e : g) //default std::fill(e.begin(), e.end(), g.size());//wrong state for(size_t i = 0; i!=stopStates; ++i) //default g[i]['i'] = stopStates, g[i]['o'] = stopStates+1; //===== stop states ===== g[0]['p'] = 8; //puton //in \ out g[1]['p'] = 12; //put //input \ output g[2]['o'] = 14; //on g[2]['p'] = 8; //puton //put_on g[3]['p'] = 8; //puton g[3]['e'] = 0; //e //===== non stop states ===== g[4]['n'] = 1; // i -> in g[5]['n'] = 6; // o -> on g[5]['u'] = 7; // o -> ou g[6]['e'] = 0; // on -> one g[7]['t'] = 1; // ou -> out g[8]['u'] = 9; // p -> pu g[9]['t'] = 10; // pu -> put g[10]['o'] = 11; // put -> puto g[11]['n'] = 0; // puto -> puton g[12]['u'] = 13; // ?p -> ?pu g[13]['t'] = 2; // ?pu -> ?put g[14]['n'] = 3; // ?puto -> ?puton g[14]['u'] = 7; // ?puto -> ?putou return g; //todo: Timus - automatic construction of a MINIMAL state machine (NP ?) }(); |
| Colleniars? | coder | 2221. Convex Hull Treap | 17 июн 2026 22:26 | 2 |
For this test what should be answer? 3 0 0 1 1 2 2 --- 1 2 3 or 1 2 2 ? (Answer written by GPT-5.5, verified with AC solution) The size of a convex hull is not the number of points in the set. According to the statement, if the convex hull is a segment, its size is 2. For the whole set, the delegate is (2, 2), because it has the greatest ordinate. The convex hull of all three collinear points is just the segment from (0, 0) to (2, 2), so its size is 2. Then Vadim takes the points to the left of the delegate: (0, 0) and (1, 1). Their delegate is (1, 1), and their convex hull is also a segment, so its size is 2. Finally, (0, 0) is alone, so its convex hull size is 1. So in input order the answer is 1 2 2. |
| O(n^2) why TL is so large for this problem? (-) | Vedernikoff 'Goryinyich' Sergey (HSE: АОП) | 2122. Хэмминг | 17 июн 2026 05:04 | 1 |
|