| Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
| 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 |
|
| WA #5 | coders1122 | 1577. Электронная почта | 17 июн 2026 02:52 | 6 |
WA #5 coders1122 28 окт 2010 20:09 see the second sample on your site. the answer is 2. Any suggestions on improvement of the algorithm i use? Is my approach wrong or can be fine with some tweaking? Ravi Kiran. If in your current state s1[i]==s2[j], you should not assume states i+1,j and i,j+1. Only i+1,j+1. Thanks a lot everyone. I got accepted with the change you suggested. Had similar problem :) This test shows the difference aba a Edited by author 17.06.2026 08:18 |
| How to do this problem using segment trees? | Pushkar Mishra | 1019. Перекрашивание прямой | 16 июн 2026 11:53 | 3 |
I understand that we are only concerned with the points mentioned, and not all the points between 1 and 10^9. After forming a segment tree and making all the updates, how can we find the longest white colored segment? Thank you. It can be solved with heap by sequentially walking on control points to add/remove active segments and tracking the latest one as of input order As for segment tree, I'd track these values iv: longest white streak on the interval lv: longest white streak at the begging of the interval rv: longest white streak at the end of the interval sv: length of segment initially iv=lv=rv=s now iv = max(iv1, iv2, rv1+lv2) lv = lv1==s1 ? s1+lv2 : lv1 rv = rv2==s2 ? rv1+s2 : rv2 But it will require lazy propagation similar to 1890 problem during painting which is quite cumbersome. The good side - it would allow "online" algorithm to give answer at every step as paiting proceeds (could be a good upgrade of a problem :) As for this one - a simpler lazy propagation with states "0" nothing "w" completely white, "b" completely black. Upon final convergion you repeatedly forward them from parent to children while you walk downwards, and after paiting all parental colorings are reverted to "0" Edited by author 16.06.2026 12:05 |
| The problem is easily solvable without segment tree. | Jorres | 1019. Перекрашивание прямой | 16 июн 2026 11:49 | 3 |
Also pay attention to the fact that according to the example - segment is (a;b]. I used this approach and got accepted. (O (N*N) btw :) ) Yes. Compressing coordinates and painting segments straightforwardly is enough. It's also easily solvable with heap at O(N*log(N)) |
| Some tests | 👨🏻💻 Spatarel Dan Constantin | 1840. Жертва рекламы | 16 июн 2026 10:30 | 1 |
Some tests 👨🏻💻 Spatarel Dan Constantin 16 июн 2026 10:30 WA #5: 2 -2000 0 -1000 0 0 -1000 0 -2000 > 367.0796326795 WA #7: 2 935 973 -16 438 867 30 196 463 > 1040.9330224527 WA #13: 2 0 7 0 8 6 10 6 1 > 12.7006778631 |
| WA 7 | Yegor | 1890. Деньги из воздуха | 16 июн 2026 10:26 | 3 |
WA 7 Yegor 19 дек 2011 03:58 What can cause a "wrong answer" in 7-th test? I used sqrt_decompostion and always get WA7. what is tricky test 7? I found my bug, I renum all vertexes, but used old indexes :) (renum all child of vertex to as id....id+k, sequencial indexes). Edited by author 15.02.2012 18:35 Since description says p[i]<i it was tempting to assume that initial sequence is already in DFS order, but it's not necessarily so. Got RE7 when explicitly checked for this. |
| To Admins: Wrong tests #8 | Dmi3Molodov | 1102. Странный диалог | 14 июн 2026 04:41 | 1 |
The total length of all strings (including the first one with the number N) exceeds the specified size of 4000000 bytes. |
| PLEASE ADD SUPPORT FOR OCAML. | Dmohan | | 13 июн 2026 19:32 | 1 |
Hi, Kindly add support for ocaml to execute timus problems. Thanks. |
| To Admins: Weak tests | Dmi3Molodov | 1242. Оборотень | 13 июн 2026 01:51 | 1 |
1) write in the assignment that family ties and victims cannot be repeated in the input, or add such tests. this is a real problem when searching for maniacs in databases. 2) write in the assignment that a werewolf cannot kill himself. |
| Please add this test. | Zayakin A. [Perm SU] | 1202. Путешествие по прямоугольникам | 12 июн 2026 06:57 | 2 |
#include <cstdio> int main() { freopen("output.txt", "w", stdout); printf("99999\n"); printf("0 0 10 100\n"); for(int i =0 ; i < 99998; ++i) { printf("%d %d %d %d\n", (i+1)*10,0,(i+2)*10 , 100); } return 0; } My early solution get AC, but must get TL. Edited by author 19.01.2011 16:05 Also this test 4 0 0 2 6 2 2 4 4 4 0 6 6 6 2 8 4 My AC solution gives 12 when correct answer is 8 |
| What is the answer for... | Nazar (Lviv NU) | 1202. Путешествие по прямоугольникам | 12 июн 2026 06:57 | 4 |
What is the answer for 2 0 0 3 3 3 2 5 7 Answer is -1? Yes (-) Michael_Rybak 15 фев 2006 18:29 What?! Why? ^ | __ | | | | | | | | | |___| | Such input gives that picture, so why there is no path?! | | | | |__| |___| ----------- > Your picture has 3,1 for lower-left corner of second rectangle |
| Why this taks can not be solved with Trie? :@@ | mes | 1414. Астрономическая база данных | 12 июн 2026 00:26 | 6 |
It's just brute-force task :) There 36 lines in my AC code versus yours 165 lines :) Edited by author 08.03.2013 19:59 thanks, now AC with set :/ It can actually be solved with trie. My solution uses 0.4s (cin) and 20MB. Just store a map in every node. Solved with C++ with tree of static arrays of links, without any STL structures Same here. 0.062 sec, 1.8Mb |
| Some tests | andreyDagger`~ | 1998. Старый падаван | 11 июн 2026 23:09 | 3 |
5 3 1 2 2 2 2 2 3 4 6 ans: 11 5 3 3 1 2 3 4 5 1 4 7 ans: 12 9 9 123 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ans: 9 Why does the last test have an answer 9? on 9th second he can't pick up the last stone, instead he drops all of them, so isn't the answer 27? |
| WA on test 6 in C++ | Mamuka Sakhelashvili [Freeuni] | 1316. Биржа | 11 июн 2026 22:45 | 5 |
I have solved this problem by Fenvic tree, at first I got WA on 5 test, then I changed int-s into long long-s and now I have WA on 6 test. If you had this kind of experience please tell me what types should I use to get AC? Thanks. The test 6 aint about data types' ranges. იდეაში, ეგ ხო ფენვიკის ხით უნდა გავიდეს, მე ვთვლი რაოდენობას, რამდენი გაყიდვა შესრულდება და შემდეგ ვამრავლებ 0.01–ზე და ვაბეჭდინებ. და ეგრე უნდა მუშაობდეს წესით ხო? Try this test BID 0.01 SALE 0.02 10 Answer:0.00 |
| Is there better solution then O(n^3) for each test? | vgu | 1221. Malevich Strikes Back! | 11 июн 2026 21:35 | 5 |
How I can do it on 0.001? Edited by author 31.10.2008 02:29 Edited by author 16.06.2009 00:42 I track w0[i][j] as length of longest horizontal stride of a[i][j]==0 starting at i,j (0 if a[i][j]==1), symmetric for w1[i][j]. Now w1[i][j] defines the length to be tested (as 2*w[i][j]+1), this is done by descending downwards. At first it seems to be O(N^3) but due to nature of the pattern you won't descend all that frequently, so I believe it's O(N^2), and it gave 0.001 AC in C++ |
| Problem description | LaVuna [KHNURE] | 1221. Malevich Strikes Back! | 11 июн 2026 21:17 | 2 |
You should find maximum matrix which is square, black and also contains white square inside rotated by 45 degrees. For instance: 1) 1 1 1 0 1 1 1 1 1 0 0 0 1 1 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 1 1 0 0 0 0 1 1 1 1 1 0 1 1 1 2) 1 1 1 1 0 1 1 1 1 1 1 1 0 0 0 1 1 1 1 1 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 1 1 1 1 1 0 0 0 1 1 1 1 1 1 1 0 1 1 1 1 are desired matrices maximum width of which you must find 1st matrix is invalid (pre-last row) |
| Can we do this in O(N) ? | Nikunj Banka | 1031. Железнодорожные билеты | 10 июн 2026 11:52 | 5 |
My solution runs in O(N logN) and it uses heap data structure. The discussion forums hint that there may be a O(N) time solution. Is there a linear time algorithm? heap?:D just use lower_bound And, BTW, Yes there is. At first I used Binary Search on each station but on the next station you can start with the previous index. code: int canReach1 = A[i] + L1; while (ind1 <= end && A[ind1] <= canReach1) ind1 ++; i've used dp (which is easy to notice) with some optimization. suppose we have three stations s1 s2 s3 and there exists path s1-s2 covered with l1, and path s1-s3 also covered with l1. then we can skip the analysis from s2. we can easily reduce used time if we create list of "allowed" stations to analyze (like s3) You can keep deque (FIFO) of pairs (max_x,total_price) if using C1 on last trip, same for C2, same for C3. All three deques will be non-descending on price (and naturally ascending on coordinate). At each step pick minimum from non-empty deques (their front element) and push new advances to their end. Edited by author 11.06.2026 06:16 |